Change os.path.exists to os.path.isfile in delete_file.

There is no reason to do any of this unless the path is a file.