> For the complete documentation index, see [llms.txt](https://docs.gpmautomate.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.gpmautomate.com/huong-dan-cac-action/file-and-folder/file-append-line.md).

# File append line

File append line là hành động dùng để chèn thêm một dòng chữ mới vào vị trí cuối cùng của một file định dạng `.txt`.

🎥 Xem thêm video hướng dẫn: [Tại đây](https://youtu.be/EH7olDLAb9c).

Khác với hành động ghi đè (File write all text), hành động này giúp bảo toàn nguyên vẹn toàn bộ những dữ liệu đã có từ trước trong file.

* Nếu file chưa tồn tại: Hệ thống sẽ tự động tạo mới file `.txt` theo đường dẫn đã chỉ định rồi tiến hành chèn dòng chữ vào.
* Nếu file đã tồn tại: Hệ thống giữ nguyên nội dung cũ, tự động xuống dòng ở cuối file và nối đuôi dòng dữ liệu mới vào.

#### Tham số cấu hình:

* File Path: Đường dẫn tuyệt đối dẫn đến file `.txt` muốn chèn thêm dữ liệu (Ví dụ: `D:\GPM\history_log.txt`).
* Text: Nội dung văn bản (hoặc biến chứa văn bản) mà bạn muốn nối thêm vào cuối file.

#### Ví dụ thực tế: Ghi nhật ký (Log) các tài khoản đã chạy thành công

Giả sử bạn chạy một kịch bản tương tác và muốn lưu lại danh sách những tài khoản đã hoàn thành nhiệm vụ vào file `success_accounts.txt` để cuối ngày tiện kiểm tra:

* Cách cấu hình: Sau khi tài khoản thực hiện xong các bước tương tác ở cuối kịch bản, bạn gọi hành động File append line:
  * File Path: Điền `D:\GPM\success_accounts.txt`.
  * Text: Truyền biến chứa tên tài khoản vào (Ví dụ: `$currentAccount`).
* Kết quả: Mỗi khi có một luồng chạy xong, tên tài khoản đó sẽ được xếp nối đuôi nhau ngay ngắn thành từng dòng trong file `success_accounts.txt` (Ví dụ: dòng 1 là `tk_01`, dòng 2 là `tk_02`...) mà không bị mất dữ liệu của các tài khoản đã chạy trước đó.

<figure><img src="/files/g8qSKxI1s1I01Tol3E4U" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.gpmautomate.com/huong-dan-cac-action/file-and-folder/file-append-line.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
