I believe File.foreach('input.txt') would read file one line at a time. Could not fine any documentation on that though. Can anyone confirm that?
Also I wanted to create a gigantic file to test the difference betwween File.forach and File.open . If the file is really large then File.open should fail and File.foreach should succeed. Anyone knows any nifty *nix trick to create a gigantic file really fast?
Update:
On further reading I found following different ways to read a file. Not sure which one would try to read all of them at the same time. Will try some cases and will update this post.
f = File.open('input.txt')
a = f.readlines
f = File.open('input.txt')
a = f.get
f = File.open('input.txt')
f.each_line{ |s| puts s}