Only open file if we actually going to write triangles to it (reduce amo...

...unt of file descriptors open)