title: Reading text file line by line using streamReader in c#
body: <p>I am trying to read text file line by line using streamReader .
  I am taking file path from textbox but it reads only last line </p>
  
  <p>this is my code for replacing stop keywords in text file .</p>
  
  <pre><code>try {
      string line;
      string path = textBox1.Text;
      MessageBox.Show("Process is start");
      //string text = System.IO.File.ReadAllText(richTextBox1.Text);
      StreamReader file = new StreamReader(path);
      MessageBox.Show(" process start reading file");
  
      string[] stopWord = new string[] {
          "is", "are", "am", "could", "will", "ing", "er", "est"
      };
  
      while ((line = file.ReadLine()) != null) {
          // MessageBox.Show("in while");
          FileStream fs1 = new FileStream(@
          "D:\temp.txt", FileMode.OpenOrCreate, FileAccess.Write);
          StreamWriter file1 = new StreamWriter(fs1);
          file1.WriteLine();
          foreach(string word in stopWord) {
              //line = line.Replace(word,Environment.NewLine);
              line = line.Replace(word, "");
          }
          file1.WriteLine(line);
          file1.Close();
      }
      /*Converting text file into binary */
      file.Close();
  }
  </code></pre>