Rearrange if statements in outputwriter.