Forgot to close open files before; added 'with' block