search: simplify event loop
Created by: camdencheek
Just a small refactor to simplify the main streaming event loop to make it more clear what the exit conditions are, etc.
- Pulls event handling into a closure
- Simplifies the for/select loop to keep variables scoped
- Inlines matchesAppend because it is a single-line closure used in one place
cc @keegancsmith @stefanhengl