in reply to flushing by default

Did you try the outflush at the top of your code?: $|++; I'm so used to it, I almost always put it in whenever I'm coding a new script.