From: Sebastian Hungerecker Date: 2008-11-05T23:21:58+09:00 Subject: Re: what's wrong about this chomp code? Lloyd Linklater wrote: > File.open('1c.txt').each { |line| puts line.chomp } File.foreach('1c.txt') {|line| puts line} File.foreach is better than File.open(...).each because that way the file is closed right away (with your code open returns a file object that you simply throw away after calling each on it, so you can't call close on it). And doing puts file.chomp is pointless as puts will just readd the \n removed by chomp. HTH, Sebastian -- Jabber: sepp2k@jabber.org ICQ: 205544826