I'm not sure how much memory this would take up, or how slow it would be, but you can always try and find out:

Code:
$f = explode("\n", file('filename.txt'));
echo $f[$randomNumber];
And then kill the array right after you've used it.