title: Why am I getting unsupportedoperation: read
body: <p>I am new to python and I am having an issue with the following syntax</p>
  <pre><code>  test_file = open(&quot;test.txt&quot;, &quot;wb&quot;)
    test_file.write(bytes(&quot;Write me to the file\n&quot;, 'UTF-8'))
    test_file.close()
    text_file = open(&quot;test.txt&quot;,&quot;r+&quot;)
    text_in_file = test_file.read() # this is where the error emerges
    # more code goes here
  </code></pre>
  <p>On this syntax, I am getting</p>
  <pre><code>io.UnsupportedOperation: read
  </code></pre>
  <p>I got it from an online tutorial and I am using python 3. do you know what could lead to such kind of error message?</p>