private static String uncommentAndTrim(final String line) {
    int cur = 0;
    while (cur < line.length()) {
      final int pos = line.indexOf('#', cur);
      if (pos < 0) return line;
      final int doublepos = line.indexOf("##", cur);
      if (pos < doublepos || doublepos < 0) return line.substring(0, pos);
      cur = doublepos + 2;
    }
    return line;
  }