Adding option to write density to file from config file.