Corrected a bug for matches at the end of the line.