Lua - write and then output simulator