updated run to write cfg file