This code
\documentclass{book}
\usepackage{answers}
\Opensolutionfile{foo}
\begin{document}
%\Writetofile{foo}{whatever} % OK
\Writetofile{foo}{\noexpand\chapter{bar}} % fails
\end{document}
produces this error
Output from handle foo going to foo.tex
(c:\eb\tex\q.aux)
! Incomplete \iffalse; all text was ignored after line 10.
<inserted text>
\fi
l.10 \Writetofile{foo}{\noexpand\chapter{bar}}
% fails
The construction worked perfectly on another computer (now broken) with a relatively new MiKTeX installation. On this windows 7 machine I'm running
C:\eb\tex>pdflatex -version
MiKTeX-pdfTeX 2.9.4902 (1.40.14) (MiKTeX 2.9)
I have looked at the related questions with a similar \iffalse error message, to no avail.
\protect: that's the LaTeX mechanism – Joseph Wright Mar 28 '15 at 20:12\protect? Instead of\noexpand? Any idea why this used to work? Please post as answer so I can accept. – Ethan Bolker Mar 28 '15 at 20:15\noexpandany more. – egreg Mar 28 '15 at 20:22