Fix output stream problem