title: Ruby I/O - File Handle Left Open
body: <p>Can anyone provide some clues as to why these two pieces of code are not equivalent?  My only thought is that the .open in the latter code portion is not in a block and the file handle is left open.</p>
  
  <pre><code>File.open(file) do |io|
    io.each_line do |line|
      body_string &lt;&lt; line
    end
  end
  </code></pre>
  
  <p>and this one</p>
  
  <pre><code>File.open(file).each_line {|line| body_string &lt;&lt; line}
  </code></pre>
  
  <p>Thanks.</p>