Save debug results to a local file ( not copying all )

I have a task that will save outputs to a local file, when I check the text file the contents are missing .
ex: I have 13 inventory host and should run each task and save the output to local file. so ideally should have all 13 results in each file.

I tried serial fork but nothing helped. can someone plz assist.

$ cat 1txt |grep IP |wc -l
13
$ cat 2.txt |grep IP |wc -l
12
$ cat 3.txt |grep IP |wc -l
13
$ cat 4.txt |grep IP |wc -l
12
$ cat 5.txt |grep IP |wc -l
12
$ cat 6.txt |grep IP |wc -l
13

  • name: save output to a file
    connection: local
    lineinfile:
    line: “IP is {{ inventory_hostname.split() | list | to_yaml }} {{ result | list | to_yaml }}”
    dest: /tmp/user.txt
    create: yes
    insertafter: EOF
    state: present
    delegate_to: localhost

I tried copy module but the output saved only last output . that’s the reason opted for lineinfile.

if you are targeting more than one host at a time, you have a
concurrency issue, multiple tasks trying to write to the same file at
the same time. Use throttle to ensure only one process is doing so.