File Read Line
A file reader that hands you a new line every run — batch testing without the spreadsheet
- line_text
- line_index
- line_count
- is_last
File Read Line is the node you want when you have a list of prompts - or seeds, or any one-string-per-line thing - and you want to work through it one at a time. You put a text file with a prompt on each line, and every time you run the graph it hands you the next line. Run again, next line. Reach the end, it wraps back to the top. It turns "test fifty prompts" into "queue the graph fifty times" instead of building fifty branches by hand or maintaining a spreadsheet of seeds.
It's the cleverest node in the TakkunRed ComfyUI-String-Function pack, and it earns its cleverness from a ComfyUI engine trick rather than anything flashy.
How it works
The node keeps an in-memory counter per node instance and returns the line at the current position, then advances. The tricky part is making ComfyUI actually re-run it - the engine aggressively caches nodes whose inputs haven't changed, and your inputs (the same file path) stay identical between runs. The author solved this the standard way: IS_CHANGED returns float("NaN"), which is never equal to itself, so ComfyUI always re-executes the node. That's the same always-rerun idiom the core engine docs describe, and it's the entire reason this node can behave like a loop counter instead of a one-shot loader.
A few behaviors worth knowing from the source:
sequentialmode walks 1 → 2 → 3 → ... → last → 1.shufflemode consumes a shuffled order with no repeats, then reshuffles when it's exhausted - useful if you're testing and don't want any prompt twice before all of them once.line_indexis the line's actual position in the file (1-based), so even with empty lines skipped it reflects where you are on disk.reset- feed itTrueon a run and the counter jumps back to the top on that same run.- The counter lives in RAM, keyed by node. Restart ComfyUI and you're back at line 1. Two separate File Read Line nodes reading the same file have independent counters.
Inputs and outputs
Set file_path (required) and you can leave everything else alone. The useful knobs: mode (sequential default, shuffle), skip_empty_lines (True if your list has blank lines you want ignored in the count), and reset for jumping back to the start.
line_text(STRING) - the current line, trailing newline removed. Wire this into your CLIPTextEncode or LLM node.line_index(INT) /line_count(INT) - where you are and how many there are, handy for a filename prefix or a preview.is_last(BOOLEAN) - True on the final line before it wraps. Wire it into logic to do something different on the last pass.
Installing it
Same story as the rest of the pack - it's pure stdlib, no dependencies, no models. Install via ComfyUI Manager (search "ComfyUI-String-Function") or:
cd ComfyUI/custom_nodes
git clone https://github.com/TakkunRed/ComfyUI-String-Function
Restart ComfyUI, and it's under String Function.
Where people get burned
- The always-rerun trick has a cost. Because this node returns
NaNfromIS_CHANGED, it defeats ComfyUI's cache for everything behind it - the engine re-executes the upstream path too. In a big workflow that can make runs feel needlessly slow. It's the price of the loop behavior; if your graph is heavy, isolate the iterative part. - Counters reset on restart. A half-consumed list starts over after you relaunch ComfyUI, so a 200-line file you were 150 lines into will begin again. There's no persistence.
- Each run advances the counter by exactly one, so if you queue the graph N times in one go, you skip N lines. That's usually what you want for batch iteration - just know it's per-queue, not per-second.
- The file-pick button next to
file_pathis Windows-only (it shells out to PowerShell); on Linux and macOS, type the path.
If your "list" lives as separate files in a folder instead of lines in one file, Folder File Read does the same trick at the file level.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| file_path | STRING | — | |
| modeopt | COMBO | sequential | 2 options: sequential, shuffle |
| resetopt | BOOLEAN | false | True を受けた実行でカウンタをリセットし先頭から再開する |
| encodingopt | COMBO | auto | 4 options: auto, utf-8, utf-8-sig, cp932 |
| skip_empty_linesopt | BOOLEAN | false | True にすると空行をスキップしてカウント |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| line_text | STRING | — |
| line_index | INT | — |
| line_count | INT | — |
| is_last | BOOLEAN | — |