Fixed IO stream closed issue