I suspect you need to drop the \n at the end of the print statement (or each print is guaranteed to be on the next line), and on each loop iteration print only the "difference" between the value of the last $done ($done_last)? and the current $done (scaled appropriately). This will append the "new stuff" to what you have already printed.