# Setting the style of the output in a text file

My problem is related to FormatType of the Output of Print[].

Look at this example code

i = 4;
Print["Try", "\tPippo : ", i, "\nPluto"]


The output is

If instead I send the output to another stream through

$Output = OpenWrite["demo.txt"]  and then I evaluate again the Print command, the output in the file “demo.txt” looks like the following How can I save the text in the same style it appears in Mathematica? For example, I want my text file to look like • does adding the option FormatType -> OutputForm, that is, using  $Output = OpenWrite["demo2.txt", FormatType -> OutputForm] give you what you need? – kglr Jan 23 '18 at 16:00
• @kglr Yes!! Thank you! – apt45 Jan 23 '18 at 16:30
• I used FormatType -> OutputForm in the Print[] and it didn't work! thank you – apt45 Jan 23 '18 at 16:30
• apt45, i posted the comment as an answer. – kglr Jan 23 '18 at 16:31
• FYI the reason this is not readily found in the Print documentation is that you normally would use Write for direct writing to files. – george2079 Jan 23 '18 at 18:10

\$Output = OpenWrite["demo2.txt", FormatType -> OutputForm]