title: convert vertically listed strings of a text file to horizontal format
body: <p>I have a text file "Test 2.txt" with the below format:</p>
  
  <pre><code>string1
  string2
  string3
  string4
  string5
  string6
  string7
  string8
  string9
  ...and so on...
  </code></pre>
  
  <p>I would like to convert it to text file "Test.txt" with below format:</p>
  
  <pre><code>string1,string2,string3
  string4,string5,string6
  string7,string8,string9
  ...and so on...
  </code></pre>
  
  <p>My code at the moment is below:</p>
  
  <pre><code>string line;
  string DatabaseFullPath = @"C:\Test2.xsr";
  
  using (var file = new StreamReader(DatabaseFullPath, Encoding.UTF8))
  {
      int count = File.ReadLines(DatabaseFullPath).Count();
  
      while ((line = file.ReadLine()) != null)
      {
          count++;
          if (count % 3 == 0)
          {
              using (StreamWriter writetext = new StreamWriter(@"D:\Test.txt"))
              {
                  writetext.WriteLine(line + '\n');
              }
          }
          else
          {
              using (StreamWriter writetext = new StreamWriter(@"D:\Test.txt"))
              {
                  writetext.Write(line + ',');
              }
          }
      }
  }
  </code></pre>
  
  <p>It seems that the StreamWriter is just overwriting each string "line" with another string "line" but I am not sure about it.</p>