<h1>Java 134 bytes</h1>
    void a(String[]a){int i=0,l=a.length;for(;i<l-1;i++)System.out.print(a[i]+((a[i].equals(a[i+1]))?" ":"\n"));System.out.print(a[l-1]);}
iterates through, and decides whether to separate with a new line or a space.