3

I have to use many write commands to write to the temporary file as follows

\newwrite\tempfile
\immediate\openout\tempfile=tempt.txt
\immediate\write\tempfile{data 1}
\immediate\write\tempfile{data 2}
\immediate\write\tempfile{data 3}
\immediate\write\tempfile{data 4}
\immediate\closeout\tempfile

Output

data 1

data 2

data 3

data 4

How to still use multiple writes but results on just one line as

data 1 data 2 data 3 data 4

I don't want to use \immediate\write\tempfile{data 1 data 2 data 3 data 4}.

Thankyou.

StackUser
  • 195

1 Answers1

5

A \write always adds a newline, however you can always collect up the tokens and write them all together.

For example this plain tex \mywrite{aaa} and \mywrite{bbb} produces a file with aaabbb

\newwrite\zz
\newtoks\zzz

\def\mywrite#1{\zzz\expandafter{\the\zzz#1}}

\mywrite{aaa}
\mywrite{bbb}




\immediate\openout\zz=\jobname.zz
\immediate\write\zz{\the\zzz}
\immediate\closeout\zz

\bye
David Carlisle
  • 757,742