Surely this can be done with a simple one line command using sed at a command line?

This works for me:
sed 's/^.*$/prepend text&append text/' inputfile.txt > result.txt
That'd get around the problem of it not altering the first and possibly last lines in the file using face's method
