I have a latex document that I want to use to write text to a plain text file.  I want macros to be expanded, so I can't use \filecontents (which just saves input verbatim to a file)
So far I have
\newwrite\metadatafile
\immediate\openout\metadatafile=\jobname-meta.txt
\immediate\write\metadatafile{Title: \jobname\开发者_Python百科string
Tags: \coursecode.\secnum.\termcode, \coursecode.\termcode, ...
Description:
...}
\immediate\closeout\metadatafile
What comes out in the text file inserts \par tokens instead of my double-newlines, and doesn't have any newlines in it at all.  How can I get newlines and have a regular plain text file?
There are two answers:  One is to just use a lot of \write statements, one for each line you want written.  That is, \write writes a line to the file, including the newline character.  So a blank line can be done with just
\write\metadatafile{}
Or you can use the primitive \newlinechar.  In plain tex the double-carat macro ^^J is aliased to \newlinechar so you can use that as well.  See pages 228 and 348 of The TeXBook.
While I have that book open, I looked up the importance of the \immediate primitive before \write.  All usages of \write cited also use \immediate.  I've tried without the \immediate and without it things don't get written.  
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论