You did not specify which OS - it looks like Unix, since you mention "tail".
The simplest way , if you still want to see the STDOUT from the original program, is to use a "tee" program that shows STDOUT on the terminal as well as pipes it to another program (Your monitor Script). This way, you script gets to read its STDIN, and take action when it sees what it wants. The user continues to see the terminal output.
I have also seen win32 versions of "tee", but it has been years since I have used it.