Minor tweaks to script that generates flat file