Reduced loop in writeSegments to include spanners from range ( 0,endSegment->tick ]
Reducing it to startSegment->tick is not possible, since we need include spanners that end in our tick range.