readline raises an EOFError when it reaches the end of the file.
file = File.new( "yourFile.txt" ) file.readline file.readline file.readline