   } else if (c === '\n' && !inQuotes) {
          row.push(cur); out.push(row); row = []; cur = '';
        } else if (c === '\r' && !inQuotes) {
        } else if (c === delim && !inQuotes) {
          row.push(cur); cur='';
        } else {
          cur += c;
        }
      }
      row.push(cur); out.push(row);
      
      if (out.length && out[out.length-1].length === 1 && out[out.length-1][0].trim() === '') out.pop();
      return out;
    }

    function detectDelimiter(text) {
      const candidat