From: Mark Bush Date: 2008-02-28T07:22:31+09:00 Subject: Re: checking for blank line Justin Collins wrote: > while (line = file.gets.strip) This will fail at eof as then file.gets will return nil. The strip should be put into the loop. You can also heavily refactor: file = File.new("test.txt", "r") while (line = file.gets) line.strip! if line.empty? puts "-----" else @array = line.split(':') if m = @array[0].match(/(title|company)/) print " #{m[1].capitalize}: " end puts "#{@array[1]}" end end file.close Also, since your input seems to have spaces after the colons, you may want to ignore those. If so, replace the split with: @array = line.split(/\s*:\s*/) -- Posted via http://www.ruby-forum.com/.