What is Indexing?
What exactly is happening that makes an indexed file faster to search?
Generally, the "indexing" means maintaining an additional data structure (or maintaining the file in a particular condition) in order to reduce the algorithmic complexity of the search. See
https://www.geeksforgeeks.org/analysis-algorithms-big-o-analysis/As
Zvony mentioned, searching sequentially through your file will have a complexity of O(n), which considering the high cost of file I/O operations is not the best thing you can achieve.
OTOH if you maintain the file ordered by one of the fields then you can achieve complexity of O(log n), which is fine, but the cost of maintaining file in order will be unbearable, even more if you want to search by several fields.
For example, in the RDBMS systems there is one field chosen for a primary key (may be segmented) and the file/table is maintained into an ordered (
B-tree) structure according to that key. That ensures search complexity with something near to the O(log n).
The additional "Indexes" on other fields are actually a separate tables consisting of pairs: <value of the field, physical address of the row>, they are also B-trees, the search into the index is with the same ~O(log n) complexity, and you can seek on the actual row directly by its physical address.
There are also other data structures besides the B-tree that can be used for the purpose, but the B-trees are the most common.