It is common to write some information out to a file to be used on a
subsequent run. But when it is time to read the file again, you only
want to do so if the file actually exists. \testfileexistence
is given an argument which is appended to \jobname,
and sets the conditional \iffileexists
appropriately. For example:
\testfileexistence{toc}%
\iffileexists
\input \jobname.toc
\fi
\testfileexistence takes an optional parameter; when
given, it will override \jobname for the root part of the file
name. For example, if you want to test for the file
answers.aux, you can do this with the following:
\testfileexistence[answers]{aux}%
\iffileexists
\input answers.aux
\fi