Fix segfault on string iteration

Previous version iterate over string waiting for whitespace character
and not stopped on '\0'.