Fixes error during remove_all after renaming an opened file