Read and write different file-types using Lua