close output file
moved tts segment to add-to-database segment to avoid duplicates
added a comment todo