file = File.open "file.txt" #1 solution would eat a lot of RAM p [*file][n-1] #2 solution would not n.times{ file.gets } p $_ file.close