in reply to about separator

split each record on \n to get individual lines.

You might also want to open your output file for writing.