title: Ruby how to write to Tempfile?
body: <p>I am trying to create a Tempfile and write some text into it. But I get this strange behavior in console</p>
  <pre class="lang-ruby prettyprint-override"><code>t = Tempfile.new(&quot;test_temp&quot;) # =&gt; #&lt;File:/tmp/test_temp20130805-28300-1u5g9dv-0&gt;
  t &lt;&lt; &quot;Test data&quot;              # =&gt; #&lt;File:/tmp/test_temp20130805-28300-1u5g9dv-0&gt;
  t.write(&quot;test data&quot;)          # =&gt; 9
  IO.read t.path                # =&gt; &quot;&quot;
  </code></pre>
  <p>I also tried <code>cat /tmp/test_temp20130805-28300-1u5g9dv-0</code> but the file is empty.</p>
  <p>Am I missing anything? Or what's the proper way to write to <code>Tempfile</code>?</p>
  <p>FYI I'm using ruby 1.8.7</p>