def write_file_lines(lines, filename, mode='wt', encoding=None):
    _make_dirs(filename)
    _open = gzip.open if filename.endswith('.gz') \
        else bzip_open if filename.endswith('.bz2') \
        else io.open
    try:
        with _open(filename, mode=mode, encoding=encoding) as f:
            for line in lines:
                f.write(line +'\n')
    except TypeError:  # Py2's bz2.BZ2File doesn't accept `encoding` ...
        with _open(filename, mode=mode) as f:
            for line in lines:
                f.write(line +'\n')
Write the content in ``lines`` to disk at ``filename``, line by line. Files
dataset/ETHPy150Open chartbeat-labs/textacy/textacy/fileio/write.py/write_file_lines