[texhax] how to copy a file within eTeX?

Reinhard Kotucha reinhard.kotucha at web.de
Tue Apr 6 12:02:17 CEST 2010

On 5 April 2010 D. R. Evans wrote:

 > In particular I thought that #2 would be essentially trivial (by --
 > horribly -- reading and writing a line at a time), but I don't see
 > how to tell when I've reached the end of the source file. The
 > discussions of \read and descriptions of file I/O don't seem to
 > explain that anywhere.

Hi Doc,
while you are reading a file you have to set \endlinechar=-1, then you
can can find the end of the file with \ifeof.  \read appends an empty
line to the file and unless \endlinechar=-1, \ifeof doesn't recognize
the end of the file.

Example (not tested):


  \read\InputFile to \buffer
  %% do something with \buffer



You can also set \endlinechar=-1 directly in front of \read and
restore it immediately after you've read a particular line.


Reinhard Kotucha			              Phone: +49-511-3373112
Marschnerstr. 25
D-30167 Hannover	                      mailto:reinhard.kotucha at web.de
Microsoft isn't the answer. Microsoft is the question, and the answer is NO.

More information about the texhax mailing list