fixed output buffer did not be closed if an exception occurred