title: Writing then reading in-memory bytes (BytesIO) gives a blank result
body: <p>I wanted to try out the python BytesIO class.</p>
  <p>As an experiment I tried writing to a zip file in memory, and then reading the bytes back out of that zip file. So instead of passing in a file-object to <code>gzip</code>, I pass in a <code>BytesIO</code> object. Here is the entire script:</p>
  <pre><code>from io import BytesIO
  import gzip
  
  # write bytes to zip file in memory
  myio = BytesIO()
  with gzip.GzipFile(fileobj=myio, mode='wb') as g:
      g.write(b&quot;does it work&quot;)
  
  # read bytes from zip file in memory
  with gzip.GzipFile(fileobj=myio, mode='rb') as g:
      result = g.read()
  
  print(result)
  </code></pre>
  <p>But it is returning an empty <code>bytes</code> object for <code>result</code>. This happens in both Python 2.7 and 3.4. What am I missing?</p>