title: StreamReader.ReadLine() doesn't consume the stream
body: <p>I am starting a new web application project where a user can upload a <code>.csv</code> file so that I can process the file. </p>
  
  <p>Currently I am able to let the user upload the file but when I try to use the <code>StreamReader</code> to read from the stream that generated from the file, it seems that the <code>StreamReader</code> cannot read from the stream properly.</p>
  
  <p>By the way, for the upload file part I followed the Microsoft tutorial <a href="https://docs.microsoft.com/en-us/aspnet/core/mvc/models/file-uploads" rel="nofollow noreferrer">here</a></p>
  
  <p>Here is the code for the View.</p>
  
  <pre><code>&lt;form method="post" enctype="multipart/form-data" asp-controller="Upload" asp-action="Upload"&gt;
  &lt;div class="form-group"&gt;
      &lt;div class="col-md-10"&gt;
          &lt;p&gt;Upload one or more files using this form:&lt;/p&gt;
          &lt;input type="file" name="files" &gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="form-group"&gt;
      &lt;div class="col-md-10"&gt;
          &lt;input type="submit" value="Upload" /&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p></p>
  
  <p>Here is my code for the Controller</p>
  
  <p>The len, len2 and p are variables for debugging purposes.</p>
  
  <pre><code>[HttpPost]
      public async Task&lt;IActionResult&gt; Upload(IFormFile file)
      {
          if (file != null &amp;&amp; file.Length &gt; 0)
          {
              var filePath = Path.GetTempFileName(); //Note: May throw excepetion when temporary file exceeds 65535 per server
              var stream = new FileStream(filePath, FileMode.Create);
              await file.CopyToAsync(stream);//
              long len = stream.Length;// 412 bytes
              StreamReader reader = new StreamReader(stream);//*
              int p = reader.Peek();//currently the next character is EoF
              var val = reader.ReadLine();
              long len2 = stream.Length;// 412 bytes
              bool end = reader.EndOfStream;// true
  
              //do some stuff here
  
              return RedirectToAction("Success");
          }
          else
          {
              return RedirectToAction("Upload_fail");//file not found
          }
      }
  </code></pre>
  
  <p>Any advice or help will be appreciated.</p>