> For the complete documentation index, see [llms.txt](https://trizen.gitbook.io/perl6-rosettacode/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://trizen.gitbook.io/perl6-rosettacode/programming_tasks/i/input_loop.md).

# Input loop

In Raku, filehandles etc. provide the `.lines` and `.words` methods which return lazy lists, and can thus they be iterated using a `for` loop...

**Line-by-line** *(line endings are automatically stripped)*

```perl
for "filename.txt".IO.lines -> $line {
    ...
}
```

```perl
for $*IN.lines -> $line {
    ...
}
```

```perl
for run(«find -iname *.txt», :out).out.lines -> $filename {
    ...
}
```

```perl
for run(«find -iname *.txt -print0», :nl«\0», :out).out.lines -> $filename {
    ...
}
```

**Word-by-word**

```perl
for "filename.txt".IO.words -> $word {
    ...
}
```
