made config file writing into a function