method

each

v1_8_6_287 - Show latest stable - Class: IO
each(...)
public

Executes the block for every line in ios, where lines are separated by sep_string. ios must be opened for reading or an IOError will be raised.

   f = File.new("testfile")
   f.each {|line| puts "#{f.lineno}: #{line}" }

produces:

   1: This is line one
   2: This is line two
   3: This is line three
   4: And so on...