Fix a bug to detect end of sentences

I fixed a bug to detect end of sentences when there are multiple sentences in input line.