If you were to just throw the file into a database, wouldn't the database's index essentially lead to the same result (b-tree, compacted using bulk-loading procedure).
True, but I wanted to create a library and a CLI without dependencies. I don't want to force an end user to install and use a database (even under the hood).