Script to tidy data and write out file.