added option to save the output to a file, and changed the output to be a structure with the xcorr-values