Here is an example:
I wrote a file 'script.vim' containing vim commands:
another line of text
yet another one^[:wq
To use it run :
vim text_file_name -s script.vim
To explain a little the script:
the first 'a' is the ex command to append text,
then the text to write in the file,
the ESC character, to write it use <ctrl-v> <ESC> keys,
':wq' to save and quit the editor.
Hope this will help you.
Have a nice day.