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

I have a list of points (e.g. {1.2,0.4}) which I export to a file using

Export[fileName, list];

I want to add a line before the end of file. For instance instead of ending the file with

1.236677 4.64567567
1.236677 4.64567567
1.236676 4.64567567

ending like

1.236677 4.64567567
1.236677 4.64567567
1.236676 4.64567567
# a blank line here

I tried appending {}, {,}, "" to the list, but none of them added a blank line.

I need this because xmgrace is not parsing the last line of the exported mathematica file: it expects a blank line before the End of File.

EDIT: As pointed out in the comments by Kuba and Pinguin Dirk, appending "" works on Windows XP (and probably others.) I'm using OS X.

share|improve this question
maybe something like: Export["foo.txt", Append[list, ""]]? – Pinguin Dirk Sep 11 '13 at 9:41
I already tried that but it doesn't work. If I use " ", it prints a new line with a white space in it. – J. C. Leitão Sep 11 '13 at 10:10
@J.C.Leitão What OS are you working on? Pinguin Dirk's solution works on WinXP. – Kuba Sep 11 '13 at 10:22
If all else fails: file=OpenAppend["file"]; Write["\n"]; Close[file] – C. E. Sep 11 '13 at 10:50
@cormullion, yep, OS X here too, and I too tried "\n". What file type are you exporting to? – Pinguin Dirk Sep 11 '13 at 12:20
up vote 4 down vote accepted

Here, on my OSX the following works

Export["tmp/foo.txt", Append[Range[10], "\n"]]

Mathematica graphics

share|improve this answer


Export[fileName, Append[list, ""], "Table"]

This should be OS-independent although I cannot check this under OS X.

share|improve this answer
Doesn't work with OSX. At least on my 9.0.1 with OSX 10.8.4 – halirutan Sep 11 '13 at 13:30

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.