Thanks for all your replies. I believe that any one of them would have solved my problem. A few days ago I wanted to include code in my post
. That code would have made no changes to the OP's code except to add input that explicitly showed the windows line endings. That would have duplicated his problem. Adding
would have fixed it. When I could not make the demo work, I settled for the verbal reply. Only later did I think to ask how I might have done it.
Had I known all your answers, I probably would have chosen to close and reopen STDIN because it best describes my intention.