Create, update file programmatically

I mean replace the original file by another one