fix broken json deps-files on the fly
make sure all inputstreams get closed in the end