Update logic for writing the title.txt file.