From: Brian Candler Date: 2009-07-07T20:23:51+09:00 Subject: Re: Breaking the loop in case of EOF Marcin G坦rski wrote: > I need to break a loop when program gets an EOF from STDIN. gets will return nil in this case. while str = STDIN.gets str.chomp! puts "String: #{str}" end Beware that "STDIN.gets" is subtly different from a bare "gets". The first always reads from STDIN. The second will read from the files named on the command line if the command line is not empty. (See also ARGF). -- Posted via http://www.ruby-forum.com/.