Reformat output and move function outputs to file as well.