fixed close stream issue