Help with a function node

It is not clear for me what information and what is the rule to append something to the file. Considering this is an access system then probably you want to log in a file each attempt made ? The flow below saves a log file (logline.txt).

[{"id":"c8c1ca3b.e4d8c8","type":"tab","label":"Dexter List","disabled":false,"info":""},{"id":"b3b4a21c.2f6c9","type":"inject","z":"c8c1ca3b.e4d8c8","name":"Trigger Flow","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":160,"wires":[["45f7c805.f01608"]]},{"id":"45f7c805.f01608","type":"file in","z":"c8c1ca3b.e4d8c8","name":"Read CSV","filename":"C:\\Users\\OCM\\.node-red\\static\\nrfiles\\dexter.csv","format":"utf8","chunk":false,"sendError":false,"x":310,"y":160,"wires":[["a97ac176.6e676"]]},{"id":"a97ac176.6e676","type":"csv","z":"c8c1ca3b.e4d8c8","name":"","sep":",","hdrin":true,"hdrout":false,"multi":"mult","ret":"\\n","temp":"","skip":"0","x":450,"y":160,"wires":[["3b798098.1b92f"]]},{"id":"b7c75a79.0c2a28","type":"debug","z":"c8c1ca3b.e4d8c8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":850,"y":260,"wires":[]},{"id":"3b798098.1b92f","type":"change","z":"c8c1ca3b.e4d8c8","name":"","rules":[{"t":"set","p":"csv","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":630,"y":160,"wires":[[]]},{"id":"61923d0.76ef2c4","type":"inject","z":"c8c1ca3b.e4d8c8","name":"Valid card","topic":"","payload":"UID003","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":140,"y":260,"wires":[["5f821927.3bafc8"]]},{"id":"5f821927.3bafc8","type":"change","z":"c8c1ca3b.e4d8c8","name":"","rules":[{"t":"set","p":"csv","pt":"msg","to":"csv","tot":"flow"},{"t":"set","p":"list","pt":"msg","to":"csv{UID : Name}","tot":"jsonata"},{"t":"set","p":"valid","pt":"msg","to":"payload in $keys(list)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":260,"wires":[["94e8cfd6.08269"]]},{"id":"76e40342.b4463c","type":"inject","z":"c8c1ca3b.e4d8c8","name":"Invalid card","topic":"","payload":"UID022","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":320,"wires":[["5f821927.3bafc8"]]},{"id":"94e8cfd6.08269","type":"function","z":"c8c1ca3b.e4d8c8","name":"Logline","func":"let pay = msg.payload;\nif (msg.valid) {\n    msg.payload = `Pass:      ${pay},${msg.list[pay]}`} else {\n    msg.payload = `Violation: ${pay}, Not in the list`    \n    }\n\nreturn msg;","outputs":1,"noerr":0,"x":540,"y":260,"wires":[["3077ba82.c54b06"]]},{"id":"47fe33d4.d0d61c","type":"comment","z":"c8c1ca3b.e4d8c8","name":"Dexter file","info":"UID, Name\nUID001,Dexter\nUID002,Dee Dee\nUID003,Mandark\nUID004,Simion\nUID005,Major Glory\nUID006,Val Hallen\nUID007,Dad\nUID008,Mom","x":140,"y":80,"wires":[]},{"id":"3077ba82.c54b06","type":"file","z":"c8c1ca3b.e4d8c8","name":"Save file","filename":"C:\\Users\\OCM\\.node-red\\static\\nrfiles\\logline.csv","appendNewline":true,"createDir":false,"overwriteFile":"false","x":680,"y":260,"wires":[["b7c75a79.0c2a28"]]}]