in reply to Executing a shell script with progress indicator

Another tip:
$| =1; should be moved out of the loop. It only needs to be executed once.