Populate results map only as needed

Also only put a line feed in the output between stdout and stderr when
appropriate.