File save upload doesn't replace existing file despite FILE_EXISTS_REPLACE
This is drupal's default behaviour and a known issue. It has been addressed a couple of ways.

The Upload File Replace module addresses this issue by swapping the filenames so the new file retains the original name. 

The Media Update module allows in situ replacement of media files (part of the Media project).

You could either make use of one of these modules, or use them as a model for your own function.