From: "Peña, Botp" Date: 2008-06-30T10:29:26+09:00 Subject: Re: File question From: Justin To [mailto:tekmc@hotmail.com] # just wondering how I would skip the first line of a file? then go, play w it using ruby ;-) # File.open('file.txt', 'r').each do |line| # # start on the 2nd line # end as always, there are many ways (depennding on your taste), eg given a file, File.open('file.txt', 'r').each do |line| p line end "1234\n" "456\n" "4321\n" "654\n" "546\n" "3456\n" "5436\n" "9879\n" "1111\n" #=> # you can skip the line by referring to it's index, File.open('file.txt', 'r').each_with_index do |line,index| next if index == 0 p line end "456\n" "4321\n" "654\n" "546\n" "3456\n" "5436\n" "9879\n" "1111\n" or just skip it by reading and discarding it File.open('file.txt', 'r') do |file| file.readline file.each do |line| p line end end "456\n" "4321\n" "654\n" "546\n" "3456\n" "5436\n" "9879\n" "1111\n" #=> # note i prefer the latter since its clearer (to me), and it does not annoy the loop ;) kind regards -botp