require 'stringio'
s = StringIO.new %{I am the very model of a modern major general.
I've information vegetable, animal, and mineral.}
puts s.pos # => 0
s.each_line { |x| puts x }
puts s.eof? # => true
puts s.pos # => 95
puts s.rewind
puts s.pos # => 0
puts s.grep /general/