Decompose stockholm writer

Easier to see where each piece of the file is written; shorter functions.