>>
>> def read_f(name)
>>     n = 0
>>     line = ""
>>     f = File.open(name)
>>     f.each_line{|line|
>>         n += 1
>>     }
>>     n
>> end

or:
n = 0; File.open(name).each { n += 1 }

The following would work unless the last line of your file did
not end in a newline:

n = File.open(name).grep(/#{$\/}/).length

-joe