writing centroids to file