user
Read a file one line at a time,
as opposed to reading the entire file at once.

Related tasks

* Read a file character by character
* Input loop.
assistant
(formerly Perl 6)
The lines method is lazy so the following code does indeed read the file line by line, and not all at once.

```
for open('test.txt').lines
{
  .say
}
```

In order to be more explicit about the file being read on line at a time, one can write:

```
my $f = open 'test.txt';
while my $line = $f.get {
    say $line;
}
```