From: Michael Fellinger Date: 2011-12-04T22:19:34+09:00 Subject: Re: 'open().each' doesn't close file On Sun, Dec 4, 2011 at 1:47 PM, Mc Ben wrote: > On Ruby 1.9.3 (win7(64)) > > Because code says more the thousand words: > ################## >  open("test.txt","r").each do end  # doesn't close file >  FileUtils.rm "test.txt"           # will fail: Permission denied > ################## > (it doesn't matter if the "do end" is filled or omitted) > > Bug, 'Feature' or my mistake? open will only close if you pass it a block directly. open('test.txt'){|file| file.each{ ... } } -- Michael Fellinger CTO, The Rubyists, LLC