in reply to code explanation

That will remove the file $path if it is a file (-f) and not a directory or symlink.