Personally, I would have a model for the text file. It would probably directly extend CModel. The model would have the getRandomWord() function, and possibly others methods too that deal with the file (inserting, deleting, etc). The model could then easily be used anywhere.
That is what models are for, anyways. Think of the text file as a storage method, just like MySQL.