def write_iter_in_file(path_to_file_write, iterable, fun_prepline=None, mode="w"):
    """
    Write a iterable as text line in file

    >>> mi_iterable = ["line1", "line2", "line3"]
    >>> write_iter_in_file("file.txt", mi_iterable)
    3

    :param path_to_file_write: path file where write
    :param iterable: Iterable where each element is a text line to write in disk
    :param fun_prepline: function with args count and line, to return a line to write in file.
    If None then apply this format each line: "{}\n".format(line.rstrip()).
    By default: None
    :param mode: mode w or a. By default: w
    :return: number of write lines
    """
    count = 0
    with open(path_to_file_write, mode) as f:
        if fun_prepline:
            for count, el in enumerate(iterable, 1):
                f.write(fun_prepline(count, el))
        else:
            for count, el in enumerate(iterable, 1):
                f.write("{}\n".format(el.rstrip()))

    return count