close stream in finally block