replace path.exists with path.isfile