From: "Peña, Botp" Date: 2008-12-22T09:47:47+09:00 Subject: Re: get first and last line from txt file - how? From: Thomas Preymesser [mailto:thopre@gmail.com] # Really? # .... # I did the tests with a test file with almost 8,000,000 lines. test w zero or one line first # My q&d code: # # f=File.open("input") # pos = 2 # f.seek(-pos, File::SEEK_END) # c = f.getc # result = '' # while c.chr != "\n" quick reaction: this would sure to fail on zero-or-one-liners that do not end w a newline, no? # result.insert(0,c.chr) # pos += 1 # f.seek(-pos, File::SEEK_END) # c = f.getc # end # f.close