Why this does not work when the lines are produced using \newline (instead of ^^J) and \StrSubstitute as follows? Thanks
\documentclass{article}
\usepackage{xstring}
\begin{document}
\def\mystrings{\noindent\StrSubstitute{%
B; new; test old; found people; sun; atom; number; life}%
{; }{\noexpand\noexpand\noexpand\newline}}
\mystrings
% B
% new
% test old
% found people
% sun
% atom
% number
% life
\newwrite\file
\immediate\openout\file=mystrings.txt
\immediate\write\file{\mystrings}
\closeout\file
\end{document}
\StrSubstituteis not expandable, it won't work in \write. – Ulrike Fischer Oct 28 '23 at 13:45\newlinehere? that adds some glue and penalties to affect tex's typesetting algorithms but doesn't do anything useful in a\write– David Carlisle Oct 28 '23 at 14:01newlinewas added to replace;with new line. And that does the job as you can see. The problem was when tryingwrite. – Krantz Oct 28 '23 at 14:09