What I do when I want to create a buffer, maybe do some pre-programmed
edits on it, and write it to disk, is write a function or user-command
to open the buffer (by :new or similar), do the necessary edits, and
close it (by :x or similar, which writes it if it is modified).
Depending on the importance of the edits, and on the values of some
window-size-related options, it may even happen unnoticed.
Best regards,
Tony.