> For the complete documentation index, see [llms.txt](https://trizen.gitbook.io/sidef-lang/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/sidef-lang/programming_tasks/r/read_a_file_line_by_line.md).

# Read a file line by line

*FileHandle.each{}* is lazy, allowing us to do this:

```ruby
File(__FILE__).open_r.each { |line|
    say line
}
```

Same thing explicitly:

```ruby
var fh = File(__FILE__).open_r
while (fh.readline(\var line)) {
    say line
}
```
