fixed newline character detection