You likely have several issues here. It would be a help to include a bit of the input and output files, but the following may help.
As you read in each line and store it in the datascript table, you will be storing content such as:
Therefore, you've done nothing to convert the pipe separated content into comma separated content. What you might want to do before putting each line into the table is use string.replace to replace | with ,. Something like: string.replace(buffer,"|",",") in the OPT_WRITEFUNCTION.
Next, table.concat can receive a second parameter, which is the delimiter to place between each element of the table when concatenating into a string. The default is no separator, so in your code table.concat will create one long string. You might try entering "\r\n" as the separator; table.concat(results,"\r\n").
Your output - output.line - should then include large string that when printed or written to file will include multiple lines of comma separated text.
If you connect a Write File operator to the Read Custom operator and write the output to a file, you should then have a file with comma separated content.