string[] str = project.Variables["userId"].Value.Split('|');
string str1 = str[0].Trim();
string oldStr = project.Variables["userId"].Value;
string newStr = str1+" | "+project.GlobalVariables["Global"+str1+"", "globVar"+str1+""]+" | "+project.GlobalVariables["Globals"+str1+"", "globVars"+str1+""];
string[] dataFromFile = File.ReadAllLines(@"Z:\ID.txt");
string[] dataToFile = dataFromFile
.Select(s=>s.Contains(oldStr)?newStr:s)
.ToArray();
File.WriteAllLines(@"Z:\ID.txt", dataToFile);