wrapp all stream.close in a finally block