title: removing additional space above last line text in textfile c#
body: <p>The following code is used by me to convert the entries in a datagrid view into a text file! (The process of creating a text file is successfull) After converting the datagrid view entries into a string I append a string from outside(This should appear on the last line of the textfile) </p>
  
  <pre><code>private void button1_Click_1(object sender, EventArgs e) // converting data grid value to single string
  {
      StringBuilder file = new StringBuilder();
      for (int i = 0; i &lt; dataGridView2.Rows.Count; i++)
      {
          for (int j = 0; j &lt; dataGridView2.Rows[i].Cells.Count; j++)
          {
              var val = dataGridView2.Rows[i].Cells[j].Value;
              if (val == null)
                  continue;//IF NULL GO TO NEXT CELL, MAYBE YOU WANT TO PUT EMPTY SPACE
              var s = val.ToString();
              file.Append(s.Replace(Environment.NewLine, " "));
          }
  
          file.AppendLine(); // NEXT ROW WILL COME INTO NEXT LINE
     }
  
     file.Append("Hello");
     using (StreamWriter sw = new
                     StreamWriter(@"C:\Users\sachinthad\Desktop\VS\Tfiles\file.txt"))
      {
          sw.Write(x);
      }   
  }
  </code></pre>
  
  <p>But when I check text file the outside string("Hello" in this scenario) appears on the last line but there is an additional space above it! How can i remove this additional space?</p>