def func_file_input(filepath,
                    comment_char='#',
                    dtype=float,
                    bool_tail=True,
                    in_keyword='PAIR',
                    cut_keyword='MAE',
                    bool_force_cut_kw=False,
                    ignore_kw='HEAD'):
    """Read input file
    
    Args:
        filepath    (str)   :   file path
        comment_char (str)  :   char used as comments when reading
        dtype       (type)  :   convert data type
        bool_tail   (bool)  :   whether append tail or not
        in_keyword (str)    :   read leading words
        cut_keyword (str)   :   read triming words
        bool_force_cut_kw(bool) :   whether force trim words exist
        ignore_kw   (str)   :   ignore keyword when reading

    Returns:
        List[List]  :   reading data
    """
    profile = []
    with open(filepath,mode='rt') as f:
        while True:
            line = f.readline()
            if len(line) == 0:
                break

            line = line.strip()
            if len(line) == 0 or line[0] == comment_char:
                continue
            
            bo = False
            lp = line.split()
            if len(lp) >= 2 and lp[0] == in_keyword:
                if bool_force_cut_kw and line.find(cut_keyword) == -1:
                    print('Error: in line: ' + line)
                    raise KeyError('cut_keyword is not found')
                ls = []
                try:
                    for tmp in lp[1:]:
                        if tmp != cut_keyword:
                            ls.append(dtype(tmp))
                        else:
                            if bool_tail is True:
                                t = lp.index(tmp) + 1
                                if len(lp) <= t:
                                    ls.append('nan')
                                else:
                                    ls.append(dtype(lp[lp.index(tmp)+1]))
                            break
                    profile.append(ls)
                except ValueError:
                    print('Error: in line: ' + line)
                    raise ValueError('cannot convert')
            elif len(lp) >= 2 and lp[0] == ignore_kw:
                pass
            else:
                print('Error: in line: ' + line)
                raise ValueError('Not correctly defined')

    return profile