included code to write file to the output tables