local filename = ...; assert(filename); local infile = assert(io.open(filename, "r")) local contents = infile:read("*all") while 1 do print(contents) io.stdout:write("> ") local command = io.stdin:read("*line") local delimiter = string.sub(command, 1, 1) if delimiter == "." then break else local other_delimiter = string.find(command, delimiter, 2) local pattern = string.sub(command, 2, other_delimiter - 1) local substitute = string.sub(command, other_delimiter + 1) contents = string.gsub(contents, pattern, substitute, 1) end end local outfile = assert(io.open("outfile", "w")) outfile:write(contents) outfile:close()