title: (StreamWriter) The process cannot access the file because its being used by another process
body: <p>Hi why dosent this work?</p>
  
  <pre><code>using (StreamWriter sw = File.CreateText(path))
  {
      for (int i = 0; i &lt; 100; i++)
      {
          sw.WriteLine(i.ToString());
      }
      int count = File.ReadLines(path).Count();
      sw.WriteLine(count.ToString());
  }
  </code></pre>
  
  <p>I got this error message: "The process cannot access the file because its being used by another process."</p>
  
  <p>So i figgured i had to put it like this:</p>
  
  <pre><code>using (StreamWriter sw = File.CreateText(path))
  {
      for (int i = 0; i &lt; 100; i++)
      {
          sw.WriteLine(i.ToString());
      }
  }
  
  using (StreamWriter sw = File.CreateText(path))
  {
      int count = File.ReadLines(path).Count();
      sw.WriteLine(count.ToString());
  }
  </code></pre>
  
  <p>But i get the same error. Iam so bad at this, someone please help me :)</p>