Sync text files (.txt) between iPhone and Mac; and edit (in-place), and search them on iPhone
Evernote is the app you are looking for. It comes with native apps for macOS and iOS along with a nice and fully functional Web app. It supports attaching text files, in-place editing, and has an excellent search functionality.

The basic (free) version should suffice for your needs, and comes with free 60 MB of monthly uploads, 25 MB of maximum note size, and sync for 2 devices. The premium plan costs less than $5 a month and boasts of a whole lot of upgrades.

Disclaimer: I have no affiliation to Evernote, and use the app sparingly, but know that the said features work in a decent manner.