appendFile

The computation appendFile file str function appends the string str, to the file file. Note that writeFile and appendFile write a literal string to a file. To write a value of any printable type, as with print, use the show function to convert the value to a string first. This operation may fail with the same errors as hPutStr and withFile.

Examples

The following example could be more efficently written by acquiring a handle instead with openFile and using the computations capable of writing to handles such as hPutStr.
>>> let fn = "hello_world"

>>> in writeFile fn "hello" >> appendFile fn " world!" >> (readFile fn >>= putStrLn)
"hello world!"
>>> let fn = "foo"; output = readFile' fn >>= putStrLn

>>> in output >> appendFile fn (show [1,2,3]) >> output
this is what's in the file
this is what's in the file[1,2,3]
Append a ByteString to a file.
Write a string to the end of a file.