i am new to php, i am trying to upload a file to a url, where php script should have the logic to check if file already exisits, it should append a value to the file name and then check again if it exisits, if not then proceed further to save it. 

Here is the while loop: 

```
$target_path = $target_path . basename( $_FILES['userfile']['name']); 
$i = 1;

while (true) {
    if (file_exists($target_path)) {
        $target_path = $i . "_" . $target_path;
        $i++;
    } else {
        break;
    }
}  

```

Now, im not sure if break; works the same as in other languages. What i am trying to do is the target path if already exists, will be updated and checked at each iteration of while loop, if it does not exists, the else should break the while loop, and later i will save the file with that name. 

It works only if the file does not exisits, after that it just fail to rename the file path. 

What is wrong here?