Changed to use the given OutputStream