there are several ways to satisfy your intentions. here are two of them:
1. set $| to a true value. this will autoflush the output stream after each print statement.
2. take a look at the htt protocol. there is e.g. the response code 206 "partial content", or the widely unknown response code 100 "continue", which both might be of interest for you.