rewrote writing of tsf file to fix node numbering issue