Forgot to put in.close() in the revised code.