Added closing of files. Cause it was dumb not to have that.