in reply to Relational textfile?

I think the first comment is a really good bet. However I would have iterated over the file calling a selection function passed in as a reference. Think of the selection function as your query, if it returns true this name should go into the list you are building. An intermediate function to build a more friendly data structure for the selectors to operate on would be handy too.