filecontents allows the overwriting of files:
The original environment
filecontents from the LaTeX kernel is documented in
filecontents is intended for passing the contents of
pack ages, 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.
filecontents lifts the restrictions:
- It allows the overwriting.
- The place for the environment is not restricted to before
\documentclass. It can also be placed in the preamble or after