in reply to changing input file updated

What exactly is not working?

Does $flag get set and cleared? How much is being read by each loop through <INPUT>? Does the replacement work?

CountZero

"If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law