Unlink original metrics.json before renaming

On Windows, if a rename targets an existing file, an exception is raised.
Use with statement for opening files