Write table at end of script