write the final result to stdout