Hi @shrey-42 , your logic is correct, only a small detail missing;
your Function node return one single item which contain all the lines, while you need to return multiple items (where each item contain one line)
I added a small modification to your code in the Function node and that should solve it, please give a try and let me know if that helps;
Also, i suggest checking this livestream, where Ivan and Tanay explained in great details how to deal with the data in n8n. Function node code;