in reply to separating every set of textline

Here is a simple approach--

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