title: StreamWriter all lines to file
body: <p><strong>C#</strong>
  I have a console app that reads and writes a get/set list of "Person" details. It works correctly up until I try to write it to a text file as well. Can somebody tell me why this  writes the last line of "Person" details into my text file instead of the whole list?    </p>
  
  <pre><code>        loadData();
  
          Console.WriteLine("All People");
          //1st query - just select all people
          var queryAllPeople = from person in people  select person;
  
          foreach (Person p in queryAllPeople)
          {
              using (StreamWriter writer = new StreamWriter("people.txt"))
              {
  
                  writer.WriteLine(p);
  
              }
              Console.WriteLine(p);
          }
  
          Console.ReadLine();
  </code></pre>