title: Why doesn't this simple Ruby program print what I expect it to?
body: <p>I have this:</p>
  
  <pre><code>require 'tempfile'
  t = Tempfile.new('test-data')
  t.open
  t.sync = true
  t &lt;&lt; "apples"
  t.puts "bananas"
  puts "contents are [#{t.read}] (#{t.size} bytes)"
  t.close
  </code></pre>
  
  <p>This prints:</p>
  
  <pre><code>contents are [] (14 bytes)
  </code></pre>
  
  <p>Why aren't the contents actually shown? I'm on Ruby 1.9.2.</p>