fixed writing triples by adding flushing