On Sun, 25 Mar 2001, Daniel Berger wrote: > Ah, crud - I forgot to mention that I *do not* want to read the entire file > into memory, which the readlines method appears to do (unless I'm mistaken). > I also would like to avoid tricks like creating temporary files. tell me whether this works for you: class IO def reverse_each(&proc) seek(0,SEEK_END) i = tell j = nil buf = "" loop do k = buf.rindex(10,-2) if k then proc.call buf.slice!(k+1..-1) else if i==0 then proc.call(buf); return self; end j,i = i,[0,i-4096].max seek(i,SEEK_SET) buf = read(j-i) + buf end end end end f = File.open("/home/matju/rsa_edit.htm","r") f.reverse_each {|x| print x } ============================= matju