title: I get the following error AttributeError: __enter__ when only using one with block
body: <p>When I try to save the file lines in a list I with the following code I get the below error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "C:\Users\emiel\AppData\Roaming\Sublime Text 3\Packages\User\Making_a_list_from_file.py", line 7, in &lt;module&gt;
      with filename as file_object:
  AttributeError: __enter__
  </code></pre>
  
  <p>This is the code:</p>
  
  <pre><code>
  with filename as file_object:
      lines=file_object.readlines()
  
  for line in lines:
      print(line.strip())
  
  </code></pre>