cleaned up writing the ouput file in tsv format