Filecontents

Coole Sache:
The environment filecontents is intended for passing the contents
of packages, options, or other files along with a document in a single
file. It has one argument, which is the name of the file to create. If
that file already exists (maybe only in the current directory if the OS
supports a notion of a ‘current directory’ or ‘default directory’) then
nothing happens (except for an information message) and the body of
the environment is bypassed. Otherwise, the body of the environment is
written verbatim to the file name given as the first argument, together
with some comments about how it was produced.
The environment is allowed only before \documentclass to ensure
that all packages or options necessary for this particular run are present
when needed. The begin and end tags should each be on a line by itself.
There is also a star-form; this does not write extra comments into the
file.