I think the $rand part should be:
Code:

$rand(1,$numtok(%:trivia.f,160))


otherwise, it always returns 1, which makes $gettok always return the first file in the list.