Gather output and print all at once.