> ## Documentation Index
> Fetch the complete documentation index at: https://docsuncv2.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# appendfile

Appends `data` to the end of the file at `path`. If the file doesn't exist, it gets created on the spot - the same way `writefile` would.

```luau theme={null}
appendfile(path: string, data: string): ()
```

`path` is relative to Seliware's workspace folder.

## Parameters

| Parameter | Type     | Description        |
| --------- | -------- | ------------------ |
| `path`    | `string` | File to append to. |
| `data`    | `string` | Content to append. |

## Returns

<code title="the function does not return a value.">void</code>

## Example

Keep a rolling log without overwriting earlier lines:

<CodeGroup>
  ```luau Example 1 theme={null}
  <<<<<<< HEAD
  appendfile("log.txt", "new log entry\n")
  =======
  -- appendfile(path: string, data: string): ()
  >>>>>>> 50e30f53759b0538759af25c9b271514aa2c9290
  ```

  ```luau Example 2 theme={null}
  local function log(message)
      appendfile("logs/run.log", `[{os.date("%H:%M:%S")}] {message}\n`)
  end

  log("script started")
  log("finished setup")
  ```
</CodeGroup>

<Tip>
  Creates the file if it does not already exist.
</Tip>
