0

enter image description here

I have

\documentclass[a4paper]{article}
\begin{document}
\newwrite\myoutfile
\immediate\openout\myoutfile=\jobname-myoutfile.txt
\immediate\write\myoutfile{
aaa
}
\immediate\closeout\myoutfile

\section{Test: Input the Result}
\input{\jobname-myoutfile.txt}
\end{document}

which gives me the external file jobname-myoutfile.txt with

aaa

inside.

How can I add new text, like bbb (in a newline!), to the outfile?

So that I will have

aaa
bbb
4
  • why are you closing the file if you want to append more? – Ulrike Fischer Apr 18 '20 at 12:04
  • @UlrikeFischer Because I do not know all the "newwrite"-commands. – cis Apr 18 '20 at 12:05
  • @UlrikeFischer Ah Ok, I think I understand – cis Apr 18 '20 at 12:07
  • 1
    @cis As soon as you close a file you cannot append to it (with just TeX facilities); you can't input it unless you first close it. – egreg Apr 18 '20 at 12:07
1

It should work like

\documentclass[a4paper]{article}

\begin{document}
\newwrite\myoutfile
\immediate\openout\myoutfile=\jobname-myoutfile.txt
\immediate\write\myoutfile{
aaa
}

\immediate\write\myoutfile{
bbb
}

\immediate\closeout\myoutfile


\section{Test: Input the Result}
\input{\jobname-myoutfile.txt}
\end{document}

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.