How to read lines of a file in Ruby

Ruby does have a method for this:

File.readlines('foo').each do |line|
    puts(line)
end

http://ruby-doc.org/core-1.9.3/IO.html#method-c-readlines

Leave a Comment