title: How to read file line by line and print to a text box c#
body: <p>I am working on a windows forms application and am wanting to take a text file from my local machine and have the application read the text file and display each line of text from the file into a textbox on the application. I am wanting to press a button on the form and have the first line of the text file display, then press the button again and have the second line display etc.. I have been looking for ways to do this and have found that StreamReader will probably be best for what I am wanting to achieve.</p>
  
  <p>I currently have the below code but it seems to print every line onto one line. If anybody can see why, it would be greatly appreciated, im sure that its something small.</p>
  
  <pre><code>private void btnOpen_Click(object sender, EventArgs e)
  {
      string file_name = "G:\\project\\testFile.txt";
      string textLine = "";
  
      if (System.IO.File.Exists(file_name) == true)
      {
          System.IO.StreamReader objReader;
          objReader = new System.IO.StreamReader(file_name);
  
          do
          {
              textLine = textLine + objReader.ReadLine() + "\r\n";
          } while (objReader.Peek() != -1);
  
          objReader.Close();
      }
      else
      {
          MessageBox.Show("No such file " + file_name);
      }
  
      textBox1.Text = textLine;
  }
  </code></pre>