A flat file makes a darned wimpy database, but in extreme cases it may suffice. Basically, you can use either fixed column widths or a magic character to define fields. Then, open your file and read/write as needed. To select only certain records, you have to scan the file and pick out the lines that match your criteria. To sort the results, you read the whole file into an array and sort that. Adding new rows by other than appending is cumbersome, as is deleting or updating rows, and if your expected usage includes the possibility of more than one user updating the file at the same time, forget it.
In other words, there's a reason why everyone around here prefers actual databases for database work. :-)