Saving the output every second. Slow but necessary for debug.