open('newline_separated_records', 'w') do |f| f.puts 'This is record one. It cannot span multiple lines.' f.puts 'This is record two.' end open('newline_separated_records') { |f| f.each { |x| p x } } # "This is record one. It cannot span multiple lines.\n" # "This is record two.\n"