There are three possibilities why this is happening that I can think off:
- WWW-DATA Ownership
- ROOT Ownership
- FTP Server Settings
The file on the server may belong to another usergroup that the FTP user is not a part of. Assuming that your web server uses the standard
www-data group, you should ensure that the FTP user has permission to write changes to this group. Alternatively you could try changing the chmod of this file to 777 meaning that anyone can write to it regardless of group. If this fails you may need to login on the SSH level to do the chmod rather than the FTP side.
Ensure that the file that you're writing to is not owned by root, at some point you may have used something like SSH to transfer though the file and this may be one of the reasons why some of your files are root.
FTP Server Settings
Finally you should ensure that the FTP server is not blocking you making an overwrite command. FTP server applications such as ProFTPD have settings that can block this, for example:
AllowOverwrite off check the config file to rule this out or alternatively a work around could be to download the file locally and make your changes as required and rather than overwriting the file, simply delete it.. and then make a new file.