I'd like to make a document which looks different each time it is built. I thought this would be pretty easy to do using the aux file; however, it seems I am misunderstanding something very basic. For a small proof-of-concept, here is a document that I thought would produce something different on its second run than on its first:
\documentclass{article}
\def\a{never ran}
\begin{document}
\a
\makeatletter\protected@write\@auxout{}{\string\def\string\a{ran}}\makeatother
\end{document}
After running pdflatex test, I can see that test.pdf indeed contains "never ran", and test.aux contains:
\relax
\def\a{ran}
However, running pdflatex test a second time changes neither file. Why not? What should I change so that the document contains ran on the second run?