# How to write output to an external text file in addition to the standard output stream?

How to write output to an external text file in addition to the standard output stream, i.e. a notebook for a session with FE and stdout for command-line session?

I expected this to work but it apparently only writes Print output:
AppendTo[
$Output, OpenWrite["out.txt", FormatType -> OutputForm] ]  A workaround using $PrePrint:
output = OpenWrite["out.txt", FormatType -> OutputForm];

• Is it possible to use PutAppend[] and not OpenWrite[]? Jun 20 '12 at 3:12
• @MaThEmAtika how about OpenAppend? Jun 20 '12 at 3:47