I was following page 216 of Knuth, but cannot get the following code to run. The error message is:

! Emergency stop.
<read 1> 

l.12 \read\fid to\temp

*** (cannot \read from terminal in nonstop modes)

I might mention that I cannot find \openin in the log file at all.


\read\fid to\temp
  • I'm confused: you say you're following The TeXbook, but show a LaTeX document… For all I know, LaTeX might have redefined some plain TeX macros, or even primitives. Is this reproducible with a plain TeX file? – ShreevatsaR Jul 4 '17 at 17:37
  • @ShreevatsaR - most TeX macros still work. Whether LaTeX disables \openin is sort of what I am trying to find out, I also tried using the plain package. – John Kormylo Jul 4 '17 at 17:40
  • 1
    For contrast, can you give a plain TeX version that works, and a LaTeX version that doesn't? It would make it easier to understand the question (at least for me). (Because even when I try to turn your example into a plain equivalent, it tries to read from the terminal, and whatever I type in the terminal ends up in the final output dvi file.) – ShreevatsaR Jul 4 '17 at 17:44
  • You've got the syntax of \openin wrong: \openin\fid=address.txt % with no braces. I also agree that this is quite confusing as-written (plain-tex is for things that only apply to plain: perhaps you mean tex-core?) – Joseph Wright Jul 4 '17 at 17:47
  • Yes I figured out the same: \openin\fid=address.txt works if you have a file named address.txt. With the brace it tries to read from the terminal, which is rather confusing. – ShreevatsaR Jul 4 '17 at 17:49

The syntax with curly braces in


is only supported by LuaTeX. The syntax for other TeX engines:


Where the file name can be ended by a space or \relax. Spaces in file names are supported in some cases with quotes:


(But that means, that quotes in file names are not supported ...)

  • As Windows forbids " anyway, for safe cross-platform work it's ruled out anyway ... (this is the thinking in l3file, for example). – Joseph Wright Jul 4 '17 at 17:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.