title: C# - Loop input until EOF
body: <p>This is my code to loop input until eof:</p>
  <pre><code>string input;
  List&lt;string&gt; s = new List&lt;string&gt;();
  while((input = Console.ReadLine()) != null &amp;&amp; input != &quot;&quot;){
     input = Console.ReadLine();
     s.Add(input);
  
  }
  
  foreach(string h in s){
     Console.WriteLine(h);
  }
  </code></pre>
  <p>The input keep looping each line until I pressed 'ctrl-z'. Each input is assigned into list s, but it seems that not all input assigned into list s.</p>
  <p>output:</p>
  <p><a href="https://i.stack.imgur.com/itox0.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/itox0.jpg" alt="enter image description here" /></a></p>
  <p>The output should be:</p>
  <blockquote>
  <p>a</p>
  <p>b</p>
  <p>c</p>
  <p>d</p>
  </blockquote>
  <p>Thanks for help;</p>