You should check for delimiting characters: if check_char in ' \t': continue