title: Cannot write to a closed TextWriter
body: <p>I am trying to write text to my txt file. After the first write the application crash with error</p>
  
  <blockquote>
    <p>Cannot write to a closed TextWriter</p>
  </blockquote>
  
  <p>My list contains links that the browser opens and I want to save all of them in txt file (like a log).</p>
  
  <p>My code:</p>
  
  <pre><code>FileStream fs = new FileStream(
                      "c:\\linksLog.txt", FileMode.Append, FileAccess.Write);
  StreamWriter sw = new StreamWriter(fs);
  
  for (int i = 0; i &lt; linksList.Count; i++)
  {
      try
      {
          System.Diagnostics.Process.Start(browserType, linksList[i]);
      }
      catch (Exception) { }
  
      using (sw)
      {
          sw.WriteLine(linksList[i]);
          sw.Close();
      }
  
      Thread.Sleep((int)delayTime);
  
      if (!cbNewtab.Checked)
      {
          try
          {
              foreach (Process process in Process.GetProcesses())
              {
                  if (process.ProcessName == getProcesses)
                  {
                      process.Kill();
                  }
              }
          }
          catch (Exception) { }
      }
  }
  </code></pre>