in reply to Show information before end of script

It sounds like you need to turn print buffering off. Try putting $| = 1; before your first print statement. this will turn Auto Flush on.