added option to write config file, main changed
main updated