title: with and closing of files in Python
body: <p>I have read, that file opened like this is closed automatically when leaving the with block:</p>
  
  <pre><code>with open("x.txt") as f:
      data = f.read()
      do something with data
  </code></pre>
  
  <p>yet when opening from web, I need this:</p>
  
  <pre><code>from contextlib import closing
  from urllib.request import urlopen
  
  with closing(urlopen('http://www.python.org')) as page:
      for line in page:
          print(line)
  </code></pre>
  
  <p>why and what is the difference? (I am using Python3)</p>