in reply to tail and grep for Windows

You might be interested in the Perl Power Tools project. Both tail and grep have implementations you might want to check out -- if for no other reason than comparison and hoovering some good ideas.

Matt

P.S. Some more info, particularly about tcgrep, in this thread.