Hi,

The first line would be

File.foreach('path/to/your/file').first

For getting the n-th line there are several ways, depending on how big 
the file is. If the file isn't too big, you may read all lines and then 
select the n-th one:

File.readlines('path/to/your/file')[n]

Otherwise I guess you'll have to loop over the lines to get the n-th 
one:

result_line = nil
File.foreach('path/to/your/file').with_index do |line, index|
  if index == n
    result_line = line
    break
  end
end

Or a bit more compact:

result_line, =
  File.foreach('path/to/your/file').with_index.find do |line, index|
    index == n
end

The comma after result_line is necessary to drop the index.

-- 
Posted via http://www.ruby-forum.com/.