io:files is only reading one line

Hi!

I’m trying to read data from a file, a .txt. This file has several lines, each one with a color, like:

blue
red
green

I’m trying to read it with io:lines(), but it only reads one line. This is my code:

nomFitxer = ("pantalles/" .. numNivell .. ".txt")  
  
ruta = system.pathForFile( nomFitxer, system.ResourceDirectory )  
local fitxer = io.open( ruta, "r" )  
  
if fitxer then -- nil if no file found  
 for line in fitxer:lines() do   
 print(index .. ": " .. line)  
 arrayColores.insert(index, line)  
 index = index + 1  
 end  
else   
 print("File not found")  
end  

Of course, I want to read all the lines in the file and insert them in arrayColores table. Any guess why it isn’t working?

Thanks!
Hector [import]uid: 36639 topic_id: 8298 reply_id: 308298[/import]

there is an SampleCode for io in the Corona-folder.
you find it under storage->file demo [import]uid: 42078 topic_id: 8298 reply_id: 29580[/import]

Solved…

My fault, it’s not that it is only reading one line, but there’s an error in line 9. Should be:

table.insert(arrayColores, line)

Thanks! [import]uid: 36639 topic_id: 8298 reply_id: 30293[/import]