change script to produce .txt file instead of .csv

Changed write.csv to write.table. Changed file name extension to .txt