import gzip


def get_io_wrapper(file_name, mode=None):
    """Get Wrapper to read a file name line by line. Useful to pass to functions which need all lines from a file

    Args:
        file_name (str): Path to file
        mode (str): Mode (usually 'r' or 'rt' or 'rb')

    Returns:
        _io.TextIOWrapper 
    """
    if file_name.strip().endswith('.gz'):
        if mode is None:
            mode = 'rt'

        return gzip.open(file_name, mode)
    else:
        if mode is None:
            mode = 'r'

        return open(file_name, mode)