// This example concatenates using StringBuilder object then writes contents of the
// StringBuilder object out to a file using streamwriter
StringBuilder textSB = new StringBuilder();
string newLine;
for(int i = 0; i < 50; i++)
{
newLine = "Line # " + i;
textSB.Append(newLine).Append("|").Append("\r\n");
}
string filePath = @"c:\output.txt";
using (StreamWriter outFile = new StreamWriter(filePath))
outFile.Write(textSB.ToString());