title: Different results when using WebRequest vs WebClient
body: <p>We have a text file that gets generated automatically and put in a web server. The task is to read the file line by line and insert the records in a database. The following code is in C#:</p>
  
  <pre><code>            WebRequest request = WebRequest.Create(url);
              WebResponse response = request.GetResponse();
              StreamReader r = new StreamReader(response.GetResponseStream());
  
              while (r.Peek() &gt; -1)
              {
                  string s = r.ReadLine().Trim();
                  //insert string into a db.
              }
  </code></pre>
  
  <p>When I do this I constantly get the entire file which ranges from 9000 - 10000 lines. On the other hand when I  use the following sometimes I get a truncated file (less lines)</p>
  
  <pre><code>            WebClient client = new WebClient();
              StreamReader r = new StreamReader(client.OpenRead(url));
  
              while (r.Peek() &gt; -1)
              {
                  string s = r.ReadLine().Trim();
                  //insert string into a db.
              }
  </code></pre>
  
  <p>Can anyone explain the difference? Why would the results be different? I was under the impression that WebClient was just a wrapper of HttpWebRequest.</p>