Fixed end-of-string bug