The number of lines of a file?

Hi, Ruby Fans :

I would like to write a simple program, which can read random line:
( file.txt has 7 lines )

1: f = File.new( "file.txt", "r" )
2: print f.readlines[ rand(6) ]

Thus I can get one line in file.txt by random. ( of course easily. )
Still, the "file.txt" will not only be a 7-lines file, right ? :wink:
How can I get the number of lines of a file ?
So that I can get one line in file.txt by random
more flexibly just like:

1: f = File.new( "file.txt", "r" )
2: print f.readlines[ rand( lines_of_file-1 ) ]

However, I don't want to "loop" the loop :frowning:
Is there any object or method I can use ?

Thanks,

polarpolar
(Is Ruby a singer?)