I have read that a good way is using ARGF.

ARGF.each do |line|
	# do something
end

with the program run as you wrote it:

my_app.rb<data.txt


On Thursday, December 5, 2002, at 11:34 AM, 
christopher.j.meisenzahl / citicorp.com wrote:

>
>
> What's the best Ruby idiom for reading data from a data file one line 
> at a time
> so that I could run the program with something like:
> my_app.rb < data.txt
>
>
> Thanks very much!
>
>
> Christopher J. Meisenzahl CPS, CSTE
> Senior Software Testing Consultant
> Spherion
> christopher.j.meisenzahl / citicorp.com
>
>
>
>