Here is a simple approach--
- Set a flag everytime a header starts.
- Grab everything for that chunk and write it to its city's file.txt.
- Reset the flag when the next header is encountered
--
when small people start casting long shadows, it is time to go to bed