error handling in outputStream