write_haystack function

Function to write haystack result data to file.