Looping Strategy: Change behaviour after first iteration
One elegant way to handle this is to parse the input into a more usable structure before transforming it to HTML. For example, each section could be represented as:

private class Section {
  final String headline;
  final List&lt;String&gt; contents = new ArrayList&lt;String&gt;();

  Section(String headline) {
    this.headline = headline;
  }

  String asHtml() {
    StringBuilder sb = new StringBuilde();

    sb.append("&lt;div&gt;").append(headline).append("&lt;/div&gt;");
    sb.append("&lt;ul&gt;");
    for (String item : contents) {
      sb.append("&lt;li&gt;").append(item).append("&lt;/li&gt;");
    }
    sb.append("&lt;/ul&gt;");

    return sb.toString();
  }
}


Note how the code clearly shows the structure of the resulting HTML.

The parsing code now has a more focused responsibility: parsing and validating the input. It has nothing to do with the output format any more.

private Iterable&lt;Section&gt; parseList(String fileContents) {
  List&lt;Section&gt; sections = new LinkedList&lt;Section&gt;();

  for (String line : fileContents.split("\n")) {
    String[] fields = line.split(":");
    if (fields.length != 2) {
      // throw some exception
    }

    if ("headline".equals(fields[0])) {
      sections.add(new Section(fields[1]));
      continue;
    }

    if (sections.isEmpty()) {
      // throw some error because "content" came before "headline"
    }

    sections.getLast().contents.add(fields[1]);
  }

  return sections;
}


I pointed out some lines with comments where you should do input validation. If you don't do this, you might get surprised by  ArrayIndexOutOfBoundsExceptions if the input string is invalid.

Building an object that represents each section has the advantage that invalid HTML cannot be produces – your current code could emit a &lt;li&gt; outside of an &lt;ul&gt;. 

Then in your main code, the sections are simply concatenated together:

StringBuilder output = new StringBuilder();
for (Sections section : parseList(...)) {
  output.append(section.asHtml());
}


The advantage of separating the responsibilities of parsing and formatting is that it is now much easier to adapt a single part (e.g. to a new input or output format). My suggestion for the Section class has to be criticized here, because it does not follow the Single Responsibility Principle: it both represents a section, and formats the output. Those should ideally be separated into two different classes, so that the formatting can vary without Section having to change.