The number of replies going in different directions seems to indicate that you should take a look at How (Not) To Ask A Question and How do I post a question effectively?.
There are any number of answers to your question, depending upon the requirements that you have and what you are already doing in your script. You could create the file locally, and copy it to the remote machine using ftp, sftp, or scp. You could open a port just for this, accepting the remote file via this port, and then feed the new file contents back over the port to the connecting/authenticating machine. You could copy the remote file to a local temp file, and run some checks/edits of it's contents and then copy it back, or any of the other suggestions that you have received.
Personally, I tend to favor using an existing protocol, such as scp or rsync plus ssh. Whether you just copy a standard file to the remote machine mostly depends upon whether these files are going to have/need local changes made to them.
in reply to edit remote files