I have a feeling that storing data in a file works only through an inject node that has to be triggered manually.
I would like the data to be stored as soon as new data comes in from a function node though. The trigger node didn't work either.
The msg.payload of a TCP output node should be connected to an file input node, like this:
[{"id":"54b54be5.ca3de4","type":"tcp in","z":"4d18212.60a81e","name":"listening","server":"server","host":"","port":"9100","datamode":"stream","datatype":"utf8","newline":"","topic":"","base64":false,"x":296,"y":206,"wires":[["90434ae1.aa9b98"]],"outputLabels":["node"]},{"id":"90434ae1.aa9b98","type":"file","z":"4d18212.60a81e","name":"","filename":"examplefile","appendNewline":true,"createDir":false,"overwriteFile":"false","x":575,"y":219,"wires":[]}]
No, you have no need for an inject node, just wire the function node to the file out node and it will write what ever the function node output in msg.payload
to the file.
You do need something upstream of the function node to cause it to run, the examples tend to use an inject node because it makes it easy to test, but what you actually use depends on the problem you are trying to solve.