Well, you really should be using the lists of lists (or better yet, records) and then you could do something like this:
set the_file to (((path to desktop) as string) & "some_file.txt")
set the_data to {{"Arum", "Devereux", "arum@devil.com", "?0.00", "cash", "11272531-17244745-46222118", "ankk-ck1h-3hga", "9/March/2004"}, {"test", "dummy 1", "testdummy@1.com", "?20.00", "CC", "11262531-17244745-46212118", "amkk-ck1h-3gga", "9/March/2004"}, {"test", "dummy 2", "testdummy@2.com", "$10.00", "cash", "11241531-17244745-46212618", "akoo-ck1h-3gma", "9/March/2004"}}
--convert the list of lists to a string of tab delimited paragraphs
set old_delim to AppleScript's text item delimiters
set AppleScript's text item delimiters to tab
repeat with i from 1 to (count the_data)
set (item i of the_data) to (item i of the_data) as string
end repeat
set AppleScript's text item delimiters to return
set the_data to the_data as string
set AppleScript's text item delimiters to old_delim
--the_data now looks like:
(*
"Arum Devereux arum@devil.com ?0.00 cash 11272531-17244745-46222118 ankk-ck1h-3hga 9/March/2004
test dummy 1 testdummy@1.com ?20.00 CC 11262531-17244745-46212118 amkk-ck1h-3gga 9/March/2004
test dummy 2 testdummy@2.com $10.00 cash 11241531-17244745-46212618 akoo-ck1h-3gma 9/March/2004"
*)
--write it:
my write_to_file(the_file, the_data, false)
--read it back in:
set read_data to paragraphs of (read file the_file)
--convert it back to the original format:
set old_delim to AppleScript's text item delimiters
set AppleScript's text item delimiters to tab
repeat with i from 1 to (count read_data)
set (item i of read_data) to (text items of (item i of read_data))
end repeat
set AppleScript's text item delimiters to old_delim
--kill the file:
do shell script "rm " & (quoted form of POSIX path of the_file)
return read_data
-->{{"Arum", "Devereux", "", "arum@devil.com", "?0.00", "cash", "11272531-17244745-46222118", "ankk-ck1h-3hga", "9/March/2004"}, {"test", "dummy 1", "testdummy@1.com", "?20.00", "CC", "11262531-17244745-46212118", "amkk-ck1h-3gga", "9/March/2004"}, {"test", "dummy 2", "testdummy@2.com", "$10.00", "cash", "11241531-17244745-46212618", "akoo-ck1h-3gma", "9/March/2004"}}
on write_to_file(the_file, the_data, with_appending)
set the_file to the_file as file specification
try
open for access the_file with write permission
if with_appending = false then set eof of the_file to 0
write the_data to the_file starting at eof
close access the_file
on error the_error
try
close access the_file
end try
end try
end write_to_file
Or even better, as I’ve mentioned before, you can write any type of data to a file using AppleScript, not just text. Try using records. Keep you data as records, write it to a file as a list of records, read it back in as a list of records:
set the_file to (((path to desktop) as string) & "some_file.txt")
set the_data to {{first_name:"Arum", last_name:"Devereux", email_add:"arum@devil.com", payment:"?0.00", payment_method:"cash", id_1:"11272531-17244745-46222118", id_2:"ankk-ck1h-3hga", payment_date:"9/March/2004"}, {first_name:"test", last_name:"dummy 1", email_add:"testdummy@1.com", payment:"?20.00", payment_method:"CC", id_1:"11262531-17244745-46212118", id_2:"amkk-ck1h-3gga", payment_date:"9/March/2004"}, {first_name:"test", last_name:"dummy 2", email_add:"testdummy@2.com", payment:"$10.00", payment_method:"cash", id_1:"11241531-17244745-46212618", id_2:"akoo-ck1h-3gma", payment_date:"9/March/2004"}}
my write_to_file(the_file, the_data, false)
set read_data to (read file the_file as (class of the_data))
do shell script "rm " & (quoted form of POSIX path of the_file) --kill the file
return read_data
-->{{first_name:"Arum", last_name:"Devereux", email_add:"arum@devil.com", payment:"?0.00", payment_method:"cash", id_1:"11272531-17244745-46222118", id_2:"ankk-ck1h-3hga", payment_date:"9/March/2004"}, {first_name:"test", last_name:"dummy 1", email_add:"testdummy@1.com", payment:"?20.00", payment_method:"CC", id_1:"11262531-17244745-46212118", id_2:"amkk-ck1h-3gga", payment_date:"9/March/2004"}, {first_name:"test", last_name:"dummy 2", email_add:"testdummy@2.com", payment:"$10.00", payment_method:"cash", id_1:"11241531-17244745-46212618", id_2:"akoo-ck1h-3gma", payment_date:"9/March/2004"}}
on write_to_file(the_file, the_data, with_appending)
set the_file to the_file as file specification
try
open for access the_file with write permission
if with_appending = false then set eof of the_file to 0
write the_data to the_file starting at eof as (class of the_data)
close access the_file
on error the_error
try
close access the_file
end try
end try
end write_to_file
Jon