added optional write file for correlate