%%% Bernd Raichle: read only first line of an input file
% You have a TeX input file with more than one line:
%
% test file 1 -- line 1 \count0=42
% test file 1 -- line 2 \count0=31415
% test file 1 -- line 3 \count0=1
% ... more lines ...
%
% You can use the following trick, if you want to process only the first line
% of this file:
%
% \endinput \input testfile
%
% This will produce the following output:
%
% test file 1 -- line 1
%
% Background:
% The primitive \endinput does not close the current file immediately. It sets
% a TeX internal flag that indicates that if the next end-of-line is processed
% the current file is closed. Thus all the tokens after the \endinput until the
% end of the line are processed. If you start reading a new file after
% \endinput this file will become the current file and it will be closed after
% the first end of line is seen.

\immediate\openout0=\jobname.out
\immediate\write0{test file 1 -- line 1 \count0=42}
\immediate\write0{test file 1 -- line 2 \count0=31415}
\immediate\write0{test file 1 -- line 3 \count0=1}
\immediate\closeout0

% ...

\endinput\input\jobname.out (\the\count0) \end
