i want to save a text to a file using the filecontents package. Here is the source code:

Hello World!

A file "test.lst" is created, but it is empty. If I use the source code

Hello World!

then the header

%% LaTeX2e file `test.lst'
%% generated by the `filecontents' environment
%% from source `javaprogrammierung' on 2021/04/08.

is written into the file, but not the text "Hello World!".

Can someone help me, why no text is written? I am using MacTeX 2021.

Thanks in advance for any help!


  • As always on the site please provide a full but minimal example so we know exactly what you are doing. Note that filecontents is in the kernel, no package needed.
    – daleif
    Commented Apr 8, 2021 at 16:59
  • 1
    Consider accepting the provided answer if it solved the problem. Commented Apr 11, 2021 at 15:10

1 Answer 1


The manual of the filecontents package states the following on the first page (see also daleif's comment below your question).

enter image description here

Notice The version of LaTeX released in Fall 2019 incorporates all of this package’s functionality (and more) into the LaTeX kernel itself. As a result, there is no longer a need for the filecontents package. Please use the new, built-in filecontents environment instead.

Update your LaTeX installation (if necessary) and start with the following minimal example (taken from the manual) and tell us if you still have problems.



This text gets written to \texttt{myfile.tex}.

  • 1
    Now it works. Thank you.
    – Soener
    Commented Apr 11, 2021 at 12:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .