Fix issue where last section wasn't written