title: python read file from a web URL
body: <p>I am currently trying to read a txt file from a website.</p>
  
  <p>My script so far is:</p>
  
  <pre><code>webFile = urllib.urlopen(currURL)
  </code></pre>
  
  <p>This way, I can work with the file. However, when I try to store the file (in <code>webFile</code>), I only get a link to the socket. Another solution I tried was to use <code>read()</code></p>
  
  <pre><code>webFile = urllib.urlopen(currURL).read()
  </code></pre>
  
  <p>However this seems to remove the formating (<code>\n</code>, <code>\t</code> etc) are removed.</p>
  
  <p>If I open the file like this:</p>
  
  <pre><code> webFile = urllib.urlopen(currURL)
  </code></pre>
  
  <p>I can read it line by line:</p>
  
  <pre><code>for line in webFile:
      print line
  </code></pre>
  
  <p>This will should result in:</p>
  
  <pre><code>"this" 
  "is" 
  "a"
  "textfile"
  </code></pre>
  
  <p>But I get:</p>
  
  <pre><code>'t'
  'h'
  'i'
  ...
  </code></pre>
  
  <p>I wish to get the file on my computer, but maintain the format at the same time. </p>