title: Why does read() not work with 'w+' or 'r+' mode in open() function python
body: <p>When ever I use the open with the 'r+' or the 'w+' parameters, It doesn't want to read the text file.</p>
  <p><strong>Inside Text Document:</strong></p>
  <p><code>hello</code></p>
  <p><strong>Python Code Examples:</strong></p>
  <p>code:</p>
  <pre class="lang-py prettyprint-override"><code>with open(file_name, 'r') as o:
      print(o.read())
  </code></pre>
  <p>output:</p>
  <pre><code>hello
  </code></pre>
  <p>code:</p>
  <pre class="lang-py prettyprint-override"><code>with open(file_name, 'r+') as o:
      print(o.read())
  </code></pre>
  <p>output:</p>
  <pre><code>
  </code></pre>
  <p>code:</p>
  <pre class="lang-py prettyprint-override"><code>with open(file_name, 'w+') as o:
      o.write('hello')
      print(o.read())
  </code></pre>
  <p>output:</p>
  <pre><code>
  </code></pre>
  <p>I also tried setting <code>o.read()</code> as a variable and then printing it, but there still was no output. If someone could please tell me why this happens, that would be great.</p>