title: Saving a HTTP get response to a file
body: <p>I can not get the HTTP response to be saved to a text file. I can make a get request and I can see that it goes through and I get the response I want but it doesn't save to a file. My code is below, I have commented out the other solution I have tried. </p>
  
  <pre><code>    protected void Button1_Click(object sender, EventArgs e)
      {
          string input = TextBox1.Text;
          string sURL;
          sURL = "http://api.urlvoid.com/api1000/key/host/" + input + "/";
          HttpWebRequest wrGETURL = (HttpWebRequest)WebRequest.Create(sURL);
          HttpWebResponse wrResponse = (HttpWebResponse)wrGETURL.GetResponse();
          StreamWriter SW = new StreamWriter(@"C:\Users\user\Desktop\API_Call_Test.txt");
          Stream DataStream = wrResponse.GetResponseStream();
          StreamReader SR = new StreamReader(DataStream);
          string AllResponse = SR.ReadToEnd();
          //var file = File.Open(@"C:\Users\user\Desktop\API_Call_Test.txt", FileMode.Create);
          SW.Write(DataStream);
          //DataStream.CopyTo(file);
          wrResponse.Close();
  
      }
  </code></pre>
  
  <p>The Wireshark analysis of the TCP stream:</p>
  
  <pre><code>    GET /api1000/key/host/mo.gov/                                HTTP/1.1
      Host: api.urlvoid.com
      Connection: Keep-Alive
  
      HTTP/1.1 200 OK
      Server: nginx
      Date: Fri, 12 Aug 2016 16:31:15 GMT
      Content-Type: text/xml
      Content-Length: 909
      Age: 0
  
  
      &lt;?xml version="1.0" encoding="UTF-8"?&gt;
      &lt;response&gt;
      &lt;details&gt;
       &lt;host&gt;host&lt;/host&gt;
       &lt;updated&gt;1463838832&lt;/updated&gt;
       &lt;http_response_code&gt;200&lt;/http_response_code&gt;
       &lt;domain_age&gt;0&lt;/domain_age&gt;
       &lt;google_page_rank&gt;0&lt;/google_page_rank&gt;
       &lt;alexa_rank&gt;0&lt;/alexa_rank&gt;
       &lt;connect_time&gt;0.005995&lt;/connect_time&gt;
       &lt;header_size&gt;959&lt;/header_size&gt;
       &lt;download_size&gt;54726&lt;/download_size&gt;
       &lt;speed_download&gt;67090&lt;/speed_download&gt;
       &lt;external_url_redirect&gt;&lt;/external_url_redirect&gt;
       &lt;ip&gt;
      &lt;addr&gt;104.16.20.39&lt;/addr&gt;
      &lt;hostname&gt;&lt;/hostname&gt;
      &lt;asn&gt;13335&lt;/asn&gt;
      &lt;asname&gt;CloudFlare, Inc.&lt;/asname&gt;
      &lt;country_code&gt;US&lt;/country_code&gt;
      &lt;country_name&gt;United States&lt;/country_name&gt;
      &lt;region_name&gt;California&lt;/region_name&gt;
      &lt;city_name&gt;San Francisco&lt;/city_name&gt;
      &lt;continent_code&gt;NA&lt;/continent_code&gt;
      &lt;continent_name&gt;North America&lt;/continent_name&gt;
      &lt;latitude&gt;37.7697&lt;/latitude&gt;
      &lt;longitude&gt;-122.393&lt;/longitude&gt;
       &lt;/ip&gt;
      &lt;/details&gt;
      &lt;page_load&gt;0.00&lt;/page_load&gt;
      &lt;/response&gt;
  </code></pre>