Display table information based on a file read in
<p>So I was able to put data from a file into a table and set the first word of each line a key. How do I display whats in the table in an order based on reading in another file with just the keys?</p>

<pre><code>-- see if the file exists
function file_exists(file)
  local f = io.open("data.txt", "rb")
  if f then f:close() end
  return f ~= nil
end

-- get all lines from a file, returns an empty
-- list/table if the file does not exist
function lines_from(file)
  if not file_exists(file) then return {} end
  lines = {}
  for line in io.lines("data.txt") do
    first_word = string.gmatch(line, "%a+") -- word
    lines[first_word] = line
  end
  return lines
end

local lines = lines_from(file)

end
</code></pre>