Skip to content

appendfile

appendfile appends string content to the end of a file at the specified path. If the file does not exist, it will be created.

This is useful for logging, accumulating data over time, or extending file contents without overwriting them.

Blocked file extensions

appendfile must reject paths whose extension is listed in the Filesystem security restrictions.

function appendfile(path: string, contents: string): ()

Parameters

Parameter Description
path The file path to append to.
contents The string content to add to the file.

Example

Appending to a file
1
2
3
writefile("file4.txt", "print(")
appendfile("file4.txt", "'Hello')")
print(readfile("file4.txt")) -- Output: print('Hello')