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

Use a while loop instead of a foreach loop. The foreach loop will wait until it has a whole array of the input, whereas a while loop will go line by line.
  • Comment on RE: Looping line-by-line through STDIN before EOF is received