Added table writing function.