Check this code:
You can't write a remote file via http.(If you could do that, every one else could change that file also.)
You need to use the local path.