fix newline bug in Scanner.next

(cherry picked from commit dd2da8c75f8cdef4e1f804ba84b85e4c6369191f)