How would I make my App read each line of a text file separately?

Hey there!

Title pretty much says it all. I need to make a function that assigns lines of text numbers maybe in an array and then randomly selects a different number and therefor a different line each scene.

Can anyone help please been stuck on it for ages.

James x

Did it all by myself. Feel like such a big boy. hahaha

function readLine() local path = system.pathForFile( "questions.data" ) local file = io.open( path, "r" ) linenumber = math.random(1, 45) for line in file:lines() do i = i + 1 if i == linenumber then question = line end end io.close( file ) file = nil end

Did it all by myself. Feel like such a big boy. hahaha

function readLine() local path = system.pathForFile( "questions.data" ) local file = io.open( path, "r" ) linenumber = math.random(1, 45) for line in file:lines() do i = i + 1 if i == linenumber then question = line end end io.close( file ) file = nil end