title: tempfile.TemporaryFile seems empty even though it's not
body: <p>I am writing to a temporary file by downloading the file from S3. When I open the downloaded file (called <code>3</code>) in my text editor, I can see all the lines of text. But my code returns nothing when I try to read the file line by line.</p>
  <p>After running the code, the temporary file is created in the directory of the Python script and doesn't disappear.</p>
  <pre><code>import tempfile
  import os
  
  import boto3
  
  s3 = boto3.client('s3')
  
  with tempfile.TemporaryFile() as tf:
    try:
      s3.download_file(
        Bucket='the-chumiest-bucket',
        Key='path/to/the/file.txt',
        Filename=str(tf.name)
      )
    except Exception as e:
      print('error:', e)
  
    tf.flush()
    tf.seek(0, os.SEEK_END)
  
    for line in tf.readlines():
      print('line:', line)
  </code></pre>
  <p>If I run</p>
  <pre><code>with open('3', 'r') as f:
    for line in f.readlines():
      print(line)
  </code></pre>
  <p>I get the lines, so this could be a workaround, but I've seen many people read lines from a tempfile using this exact method.</p>
  <h3>Expected Result:</h3>
  <p>I get the lines within <code>file.txt</code> printed.</p>
  <h3>Actual Result:</h3>
  <p>I get nothing printed.</p>
  <h2>Edit #1</h2>
  <p>Changed <code>tf.seek(0, os.SEEK_END)</code> to <code>tf.seek(0, os.SEEK_SET)</code> (thanks @Barmar) and still no lines being printed. Just one blank line.</p>