Proper handle stdout and stderr