title: CSV Line Breaks
body: <p>I'm building a csv file from database values. When I open the csv in excel everything is on one row. To counter this I've added either <code>\n</code> or <code>\r</code> after each row. Now when I open in excel starting at the second row there is an empty value throughout the rest of the first column.</p>
  
  <p>IE:</p>
  
  <pre class="lang-none prettyprint-override"><code>value 1, value 2, value 3
         , value 1, value 2, value 3
         , value 1, value 2, value 3
         , value 1, value 2, value 3
  </code></pre>
  
  <p>I can add a newline or return before the first value, but then there is an empty row and column. How can I get this lined up?</p>
  
  <p>My code:</p>
  
  <pre><code>try
  {
      connection = new iDB2Connection(connectionString);
      connection.Open();
      command = new iDB2Command(commandString, connection);
  
      reader = command.ExecuteReader();
      var dt = new DataTable();
      dt.Load(reader);
  
      List&lt;string&gt; CsvList = new List&lt;string&gt;();
  
      foreach (DataRow row in dt.Rows)
      {
          foreach (var item in row.ItemArray)
          {
              CsvList.Add(item.ToString());
          }
          if (i == 1)
          {
              CsvList.Add(" ");
              CsvList.Add("Customer Service");
              CsvList.Add("Customer Service Representative" + "\r"); 
              // \r and \n not working
          }
      }
  
      System.IO.StreamWriter streamWriter;
      streamWriter = new System.IO.StreamWriter(fileName, true);
  
      string CsvString = string.Join(",", CsvList.ToArray());
      streamWriter.WriteLine(CsvString);
      streamWriter.Close();
      Console.WriteLine("File saved as " + fileName);
  
      i++;
  }
  </code></pre>