<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def validate_line(self, line):
 """Validate Unicode IPA string relative to panphon. line -- String of IPA characters. Can contain whitespace and limited punctuation. """

        line0 = line
        pos = 0
        while line:
            seg_m = self.ft.seg_regex.match(line)
            wsp_m = self.ws_punc_regex.match(line)
            if seg_m:
                length = len(seg_m.group(0))
                line = line[length:]
                pos += length
            elif wsp_m:
                length = len(wsp_m.group(0))
                line = line[length:]
                pos += length
            else:
                msg = 'IPA not valid at position {} in "{}".'.format(pos, line0.strip())
                # msg = msg.decode('utf-8')
                print(msg, file=sys.stderr)
                line = line[1:]
                pos += 1