adding newline detection