If you're on a unix-like system, all your problems could be solved if you can replace your logfile by a fifo pipe. Then you can have the application that produces the logfile write to it and comfortably read from it. After processing, you can do with the lines as you please (write them to an additional (real) logfile or discard them...)