Output each line in a file and close it
file = File.open( "myFile.txt" ) file.each { |line| print "#{file.lineno}. ", line } file.close