Well I would read the whole text file into a string array at game start, so you don't have to read from the file during the game.
Code:
var names_max = 100;
string name_file = <my_names.txt>;
text names { strings=100; }
function names_store
{
var i;
var fhandle;
fhandle = file_open_read(name_file);
if(fhandle)
{
i = 0;
while(i < names_max)
{
file_str_read(fhandle,names[i]);
i += 1;
}
file_close(fhandle);
}
}
//Now in the game:
var randtemp;
...
randtemp = random(names_max);
str_cpy(my.string1,names[randtemp]);
//Now my.string1 contains a random name from the list