Fixed issues with creating the output stream.