Move TREC file writing to separate class