You could just create the array with nothing in it and add elements to the array as you need them with ARRAY INSERT AT BOTTOM. That way there's no need to even know how many lines are in the file before starting. Once the file is fully loaded then you'll know the size of the array if you need that for any randomization limits.
` Create an array with zero elements
dim Tex$()
` Make random number picking more random
randomize timer()
` Check if the file exists
if file exist("Test.txt")
` Delete the old file
delete file "Test.txt"
endif
` Create a new text file
open to write 1,"Test.txt"
` Pick a random end point
EndFile=rnd(200)
` Add strings to the file to the random point
for t=0 to EndFile
` Write the string
write string 1,"Test #"+str$(t)
next t
` Close the file
close file 1
` Open the file
open to read 1,"Test.txt"
` Do this until the file ends
while file end(1)=0
` Add an element to the array
array insert at bottom Tex$(0)
` Add the string from the file to the array
read string 1,Tex$()
endwhile
` Close the file
close file 1
` Show the array
for t=0 to array count(Tex$(0))
print Tex$(t)
next t
print "Total Array Count = "+str$(array count(Tex$(0)))
wait key