title: How to fill a list from an external file using streamreader
body: <p>how do i make a list of words in (List words) and fill it with a method void ReadWords(string, List. this method has to get the name of the file: text and the list must be filled with the words from this file.</p>
  
  <p>so how do i do this?</p>
  
  <p>i started with this:</p>
  
  <pre><code>List&lt;string&gt; woorden = new List&lt;string&gt;();
  
  // Read the file and display it line by line.
  System.IO.StreamReader file = new System.IO.StreamReader("txt.txt");
  
  int counter = 0;
  
  while (!file.EndOfStream)
  {
       string woord = file.ReadLine();
  
       for (int i = 0; i &lt; woord.Length; i++)
            counter++;
  
  }
  Console.WriteLine(counter);
  file.Close();
  Console.ReadKey();
  </code></pre>