before renaming the file checking file exists