Fixed the resetting of the json file on removal failures

Closes #3329