# open the file file = File.open('foo.txt') # iterate over each line file.each_line do |line| puts line end # close the file afterwards file.close