in reply to Not printing when expected.

It looks like you might be suffering from buffering. Try setting $|=1.