# Findfirst and eachline

**URL:** <https://discourse.julialang.org/t/findfirst-and-eachline/129165>\
**Category:** General Usage\
**Created:** [May 20, 2025, 7:58am UTC](https://discourse.julialang.org/t/findfirst-and-eachline/129165 "2025-05-20T07:58:53Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [May 20, 2025, 9:10am UTC](https://discourse.julialang.org/t/findfirst-and-eachline/129165/4 "2025-05-20T09:10:06Z")

</div>

FWIW, the following options avoid `collect()`:

```julia
for (i, r) in enumerate(eachline(file))
   contains(r, "Stack") && return i
end

```

or:

```julia
first(first(Iterators.filter(x -> contains(x[2], "Stack"), enumerate(eachline(file)))))

```

but not as simple/nice as the wished syntax.

---

_[View the full topic](https://discourse.julialang.org/t/findfirst-and-eachline/129165)._
