title: Python IOError: File not open for reading
body: <p>I get an error when I try to open a file in Python. Here is my code :</p>
  
  <pre><code>&gt;&gt;&gt; import os.path
  &gt;&gt;&gt; os.path.isfile('/path/to/file/t1.txt')
  &gt;&gt;&gt; True
  &gt;&gt;&gt; myfile = open('/path/to/file/t1.txt','w')
  &gt;&gt;&gt; myfile
  &gt;&gt;&gt; &lt;open file '/path/to/file/t1.txt', mode 'w' at 0xb77a7338&gt;
  &gt;&gt;&gt; myfile.readlines()
  Traceback (most recent call last):
  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  IOError: File not open for reading
  </code></pre>
  
  <p>I also tried:</p>
  
  <pre><code>for line in myfile:
      print(line)
  </code></pre>
  
  <p>and I got the same error. Does anybody know why this error occurs?</p>