'This method helps in grouping keys with common appendable values and
writing all keys to the file.
:param append_keys: The keys that have to be written with an append
delimiter.
:param other_keys:  The keys that have to be written with a normal
delimiter.
:param val:         The value to be written for the keys.
:param defaults:    The defaults of the section the keys and value are
to be written to.'

def __write_keys_val_to_file(self, append_keys, other_keys, val, defaults):

    if append_keys:
        append_keys = sorted(append_keys, key=(lambda key: len(defaults[str(key)])), reverse=True)
        write_keys = []
        def_val = None
        for key in append_keys:
            if (str(defaults[key]) == def_val):
                write_keys.append(key)
                continue
            else:
                if write_keys:
                    append_val = self.__get_append_val(val, def_val)
                    self.__write_value(write_keys, append_val, self.__key_value_append_delimiter)
                write_keys = [key]
                def_val = str(defaults[key])
        append_val = self.__get_append_val(val, def_val)
        self.__write_value(write_keys, append_val, self.__key_value_append_delimiter)
    if other_keys:
        self.__write_value(other_keys, val, self.__key_value_delimiter)
