Fixing an indefinite loop with unterminated string.

Hello srad,

This is a fix for unterminated strings which caused an infinite loop. 

I just got it to work but you may want to refactor this into a bit into your style.