// if text trails with \n, drops the line before that static S dropLastLine(S s) { s = dropSuffix("\r", dropSuffix("\n", s)); int i = s.lastIndexOf('\n'); ret i < 0 ? "" : dropSuffix("\r", substring(s, 0, i)); }