write stdout and stderr to file