> 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/automate-en/action-guides/file-and-folder/read-random-line.md).

# File read random line

File read random line is the action of opening an existing `.txt` text file, randomly selecting any line from that file, and then saving the content of the selected line into an output variable.

This action is extremely useful when you manage social media accounts (Facebook, X, Instagram...) and want to randomly retrieve a comment, a status, or a search keyword to avoid repeating the same content across profiles.

#### Configuration parameters:

* File Path: The absolute path to the `.txt` file containing the available data on your computer.
* Output variable: The name of the variable that stores the content of the randomly selected line.

#### Practical example: Automatically comment randomly to avoid spam

Suppose you have prepared a file with a list of positive comments stored at `D:\GPM\comments.txt`, with each comment on a separate line:

```
Great post, my friend!
Absolutely wonderful.
Very useful information, thank you to the author.
```

When the script navigates the browser to a post and is about to click comment, you configure as follows:

* Configuration method:
  * Call the File read random line action.
  * File Path: Enter the path `D:\GPM\comments.txt`.
  * Output variable: Name the variable that stores the result as `$randomComment`.
* Result: Each time the flow reaches this step (or each profile runs independently), the system will automatically randomly select one of the three lines above (For example: Profile 1 selects line number 3: `"Very useful information, thank you to the author."` and assigns it to the variable `$randomComment`). You just need to call the Key press action to input this variable into the comment box on the website.

<figure><img src="/files/RhxeGU6AudCZnTMBPrYB" 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/automate-en/action-guides/file-and-folder/read-random-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.
