Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Note: this is fixed in version 9.

I want to put expressions into multiple files simultaneously, with the following code:

tex1 = OpenWrite["test1.txt"];
tex2 = OpenWrite["test2.txt"];

Write[{tex1, tex2}, "anything"]


Why is test2.txt empty? Why does it work correctly with WriteString instead of Write? Now of course I can always Map the Write statements over streams, or just go with WriteString, but since it would be convenient to use a list as Write's first argument I did post this issue. Is it a bug?

share|improve this question
@ArnoudBuzing, what do you think of this? – rcollyer Jan 31 '12 at 15:42
It seems like a possible bug. I will report it. – Arnoud Buzing Feb 1 '12 at 0:37
@ArnoudBuzing István has indicated that this bug has been unfixed for at least 5 years:… – Mike Honeychurch Feb 1 '12 at 1:30
@ArnoudBuzing: Thanks for reporting it. This raises another meta question in me... – István Zachar Feb 1 '12 at 9:33
up vote 4 down vote accepted

This is a bug and fixed in the development version. Thanks for pointing it out.

share|improve this answer

According to the docs, both Write and WriteString should accept an "output channel," which is just a list of streams. On my system (v.8 on MacOS), Write behaves the same way as on your system when outputting anything, but WriteString behaves as expected.

Similarly, this

Write[{tex1, tex2}, 3, 4];

also misbehaves in the same manner. So, the issue isn't limited to string output.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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