each word reading : each « File Directory « Ruby






each word reading


# Create a file...
open('end_separated_records', 'w') do |f|
  f << %{This is record one.
It spans multiple lines.ENDThis is record two.END}
end

# And read it back in.
open('end_separated_records') { |f| f.each('END') { |record| p record } }
# "This is record one.\nIt spans multiple lines.END"
# "This is record two.END"

 








Related examples in the same category

1.Read line by line with each