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

# writefile

> Menulis Lua string bytes ke file di dalam workspace, membuat missing parent directories, dan mengganti file contents jika file sudah ada.

<div className="real-function-page">
  ```lua theme={null}
  writefile(path: string, content: string)
  ```

  ## Alias

  * `writefileasync`

  ## Argumen

  <ParamField path={"path"} type={"string"} required>
    File path yang di-resolve di dalam workspace setelah separator normalization, workspace-boundary checks, dan filename/extension checks. Absolute paths hanya diterima jika resolve di dalam workspace.
  </ParamField>

  <ParamField path={"content"} type={"string"} required>
    Lua string bytes yang ditulis. Data ditulis dalam binary truncate mode; writefile tidak menambahkan newlines, BOM bytes, null terminators, atau extra bytes lain.
  </ParamField>

  ## Contoh

  Tulis bytes ke workspace file dan ganti existing contents apa pun.

  ```lua theme={null}
  local path = "examples/config.json"

  writefile(path, '{"enabled":true}')
  print(readfile(path))

  writefile(path, "")
  print(#readfile(path))
  ```
</div>
