in reply to Looping line-by-line through STDIN before EOF is received

Did you look at the eof function? I would imagine it will help with what you're doing, the example code looks similar to what you're attempting.
  • Comment on Re: Looping line-by-line through STDIN before EOF is received