title: Lua read text file to array
body: <p>How can I read a file like this:</p>
  
  <pre><code>11111
  10001
  10001
  10001
  11111
  </code></pre>
  
  <p>To a bidimensional array like this:</p>
  
  <pre><code>{{1, 1, 1, 1, 1},
   {1, 0, 0, 0, 1},
   {1, 0, 0, 0, 1},
   {1, 0, 0, 0, 1},
   {1, 1, 1, 1, 1}}
  </code></pre>
  
  <p>In Lua?</p>
  
  <p>This is what I thought of:</p>
  
  <pre><code>for i = 1, number_of_lines do
    current_line = map_file:read("*line")
    character_array = {}
    for i = 1, #current_line do
      table.insert(character_array, current_line[i])
    end
  end
  </code></pre>
  
  <p>However, I don't know how to get 'number_of_lines', this is, the number of lines in a text file with Lua. How can I do it?</p>
  
  <p>Also, if there's some other easier way please tell me about it.</p>