LaTeX provides a <code>filecontent</code> environment to embed text in your document
which is written to
a external document when your process it. The filename is given with
the argument for the environment.
You could define
a environment for the same effect with the buffer mechanism, the codefor such a environment is: