How check if a file exists in ansible windows?

So I didn't use the win_stat module correctly,

Should have added the register argument in my first 'task'.

This is how it works-

- name: Check that the ABC.txt exists
  win_stat: path= 'C:\ABC.txt'  
  register: stat_file

- name: Create DEF.txt file if ABC.txt exists 
  win_file:
    path: 'C:\DEF.txt'
    state: touch
  when: stat_file.stat.exists == True

When I tried the answer above, it gave me a syntax error, instead I had to write it this way:

- name: Check that the ABC.txt exists
  win_stat: 
    path: 'C:\ABC.txt'  
  register: stat_file

- name: Create DEF.txt file if ABC.txt exists 
  win_file:
    path: 'C:\DEF.txt'
    state: touch
  when: stat_file.stat.exists == True

Tags:

Ansible