Optimize write calls for progressbar.