in reply to how to erase screen output?

You might look at the source code for Smart-Comments.

You might not use the module, but you're sure to learn something about making progress bars. It has a variety of progress bar styles.

Cheers!