PutAppend
✖
PutAppend
appends expr to a file.
Details and Options

- PutAppend works the same as Put, except that it adds output to the end of the file, rather than replacing the complete contents of the file.
- PutAppend[…,OutputStream[…]] will append to the given stream.
- expr>>>"filename" is equivalent to expr>>>fileame. The double quotes can be omitted if the file name is of the form specified in "Operator Input Forms".
- It is conventional to use names that end with .wl or .m for files containing Wolfram Language input.
- PutAppend works with cloud objects.
- PutAppend by default uses the character encoding "PrintableASCII" when appending to a file. Add the option CharacterEncodingenc to specify a different encoding.
- When writing to an open file or to its OutputStream object, the current encoding of the output stream will be used by default. Add the option CharacterEncodingenc to temporarily change the encoding of the stream for the duration of PutAppend.
- PutAppend[…,File["file"]] is also supported.
Examples
open allclose allBasic Examples (1)Summary of the most common use cases
Set the current directory to one for temporary files:

https://wolfram.com/xid/0rs0kc96q-1quyqy
Compute a value and save it in a file using Put:

https://wolfram.com/xid/0rs0kc96q-czju2s
The file now contains the value:

https://wolfram.com/xid/0rs0kc96q-gqbkkz
Compute another value and save it in the same file using PutAppend:

https://wolfram.com/xid/0rs0kc96q-xwlgb7
The file contains both results:

https://wolfram.com/xid/0rs0kc96q-8a5nzj

https://wolfram.com/xid/0rs0kc96q-b9j8zj
Scope (3)Survey of the scope of standard use cases
Create a cloud object storing a value:

https://wolfram.com/xid/0rs0kc96q-vqh2on

Append additional values to the cloud object:

https://wolfram.com/xid/0rs0kc96q-naktvd


https://wolfram.com/xid/0rs0kc96q-8hl1ij

Import the values back into the current session:

https://wolfram.com/xid/0rs0kc96q-rvo75y

Append expression to the file specified by the File object:

https://wolfram.com/xid/0rs0kc96q-juag3f


https://wolfram.com/xid/0rs0kc96q-6n8w0a

https://wolfram.com/xid/0rs0kc96q-xqumqa

https://wolfram.com/xid/0rs0kc96q-e46ohk
Create a file and open it for writing:

https://wolfram.com/xid/0rs0kc96q-n1ev2e

Put several expressions to the stream:

https://wolfram.com/xid/0rs0kc96q-mvzh7e

https://wolfram.com/xid/0rs0kc96q-5sopa7

The file contents were written using the CharacterEncoding option of the stream:

https://wolfram.com/xid/0rs0kc96q-hte2r0
Options (1)Common values & functionality for each option
CharacterEncoding (1)
By default, the encoding "PrintableASCII" is used when writing to files:

https://wolfram.com/xid/0rs0kc96q-6qhu2b
Special characters are written out as long names, which ensures they can be read on any system:

https://wolfram.com/xid/0rs0kc96q-fle0ve

Specify the common encoding "UTF-8":

https://wolfram.com/xid/0rs0kc96q-uacv0l
Special characters are written directly in the encoding, saving space at the cost of portability:

https://wolfram.com/xid/0rs0kc96q-7g2b46

Applications (1)Sample problems that can be solved with this function
Create the first value that will be stored in a temporary file:

https://wolfram.com/xid/0rs0kc96q-em3baf
Set the current directory to one for temporary files:

https://wolfram.com/xid/0rs0kc96q-bqgnsu
Put the value of x in a file:

https://wolfram.com/xid/0rs0kc96q-7j6h0c
Update x and append the new value to the file:

https://wolfram.com/xid/0rs0kc96q-60ujrm
The file now contains the two values:

https://wolfram.com/xid/0rs0kc96q-0nm4mx
Append successive iterates to the file in a loop:

https://wolfram.com/xid/0rs0kc96q-vzp3qf

https://wolfram.com/xid/0rs0kc96q-i7lym9
Compare the last line with a direct computation:

https://wolfram.com/xid/0rs0kc96q-e4k9so

Reset to the original directory:

https://wolfram.com/xid/0rs0kc96q-giq7ak
Properties & Relations (2)Properties of the function, and connections to other functions
PutAppend will create a file if the named file to append to does not exist:

https://wolfram.com/xid/0rs0kc96q-jppba3

https://wolfram.com/xid/0rs0kc96q-9ediox

https://wolfram.com/xid/0rs0kc96q-xhcn2o
Even though file was deleted, PutAppend recreated the file and stored the result in it:

https://wolfram.com/xid/0rs0kc96q-17xyxh
PutAppend always adds to file contents:

https://wolfram.com/xid/0rs0kc96q-dq2hgm

https://wolfram.com/xid/0rs0kc96q-jb077o
Both expressions are in the file:

https://wolfram.com/xid/0rs0kc96q-c8kv6v
Use Put to overwrite existing file contents:

https://wolfram.com/xid/0rs0kc96q-dp87h7

https://wolfram.com/xid/0rs0kc96q-i7i7wo
Possible Issues (1)Common pitfalls and unexpected behavior
The form expr>>>filename treats filename as a literal name, not an expression to be evaluated:

https://wolfram.com/xid/0rs0kc96q-pf1qwg


https://wolfram.com/xid/0rs0kc96q-8w0cxz
The file that was written is called "file", not the name contained in the variable file:

https://wolfram.com/xid/0rs0kc96q-cpitp3


https://wolfram.com/xid/0rs0kc96q-safzw7

Use the form PutAppend[expr,filename] to write to the file whose name is stored in file:

https://wolfram.com/xid/0rs0kc96q-nw0sth

Wolfram Research (1988), PutAppend, Wolfram Language function, https://reference.wolfram.com/language/ref/PutAppend.html (updated 2016).
Text
Wolfram Research (1988), PutAppend, Wolfram Language function, https://reference.wolfram.com/language/ref/PutAppend.html (updated 2016).
Wolfram Research (1988), PutAppend, Wolfram Language function, https://reference.wolfram.com/language/ref/PutAppend.html (updated 2016).
CMS
Wolfram Language. 1988. "PutAppend." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2016. https://reference.wolfram.com/language/ref/PutAppend.html.
Wolfram Language. 1988. "PutAppend." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2016. https://reference.wolfram.com/language/ref/PutAppend.html.
APA
Wolfram Language. (1988). PutAppend. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/PutAppend.html
Wolfram Language. (1988). PutAppend. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/PutAppend.html
BibTeX
@misc{reference.wolfram_2025_putappend, author="Wolfram Research", title="{PutAppend}", year="2016", howpublished="\url{https://reference.wolfram.com/language/ref/PutAppend.html}", note=[Accessed: 21-June-2025
]}
BibLaTeX
@online{reference.wolfram_2025_putappend, organization={Wolfram Research}, title={PutAppend}, year={2016}, url={https://reference.wolfram.com/language/ref/PutAppend.html}, note=[Accessed: 21-June-2025
]}