I still think you're doing it in a very, very, very bad way. Think about what happens when you simply use the writeconf method that's in DOSBox:
- DOSBox loads its own configuration file.
- You change settings and trigger DOSBox own configuration writing code.
- DOSBox writes its own configuration file.
Since the only thing changed are the settings you want to change, the end result is that only those are changed in the config file. Yes, behind the scenes it's been written from the start, but that doesn't matter.
Doing it that way will ensure that it keeps working even if DOSBox' config format changes (and in fact, the cycles line is one of those that has changed in the current CVS version) and works even if the cycles change from 100 to 100000 (yes, I have certain configs where it's set to 100000 cycles).
You're making things *way* too difficult on yourself and introducing too many opportunities for errors.
My site: Ramblings on mostly tech stuff.