fixed outstream closed multiple times