function write_emails() local locales = { "de", "en" } local files = {} local key for key in locales do local locale = locales[key] files[locale] = io.open(basepath .. "/emails." .. locale, "w") end local faction for faction in factions() do -- print(faction.id .. " - " .. faction.locale) files[faction.locale]:write(faction.email .. "\n") end for key in files do files[key]:close() end end