Close InputStream and OuputStream after use

Found with Kohsuke's file-leak-detector.