Read file line by line into array
<p>sorry i am still learning about lua. could you correct me, why the data from file wont read line by line ?</p>

<p>this is my example data in file <strong>points.txt</strong> : </p>

<pre><code>lexxo:30:1
rey:40:2
lion:40:2
prince:50:3
royal:50:3
</code></pre>

<p>so when i got from above is the 2d array(table)</p>

<pre><code>player = {{(name),(points),(which var point earned on index)},
          {(...),(...),(...)}};
</code></pre>

<p>so the problem is, when i try to loop for printing all of data in file. it just print only the lastest line. so what i wanted print all of them</p>

<pre><code>line_points =  {}
player_data = {{}}

local rfile = io.open("points.txt", "r")
for line in rfile:lines() do
    playername, playerpoint, playeridpoint = line:match("^(.-):(%d+):(%d+)$")
    player_data = {{playername, playerpoint, playeridpoint}}
    line_points[#line_points + 1] = player_data
end

for i = 1, #player_data do
    player_checkname = player_data[i][1] -- Get Player Name From Array for checking further
    player_checkpnt = player_data[i][3] -- Get Player ID Point From Array for checking further
    print(i..". Name: "..player_data[i][1].." Point: ".. player_data[i][2] .. " ID: " .. player_data[i][3]);
end
</code></pre>