Okay, thanks Yuriy. I solved the error by using TStringList.IndexOf, because when the list is sorted it uses a binary search. That search works, but mine doesn't--oddly enough.

To paste code like that, disable HTML in your post. That's the culprit.