#! /usr/bin/ruby STDIN.each { |s| (addr, pos, f) = s.split() pos = pos.to_i fd = File.open(f) fd.seek(pos) n = pos fd.each { |s| break if n != pos && s =~ /^From\s+/ puts s n += s.length } }