title: Chef, File does not exists after force the creation
body: <p>I have the following logic in a recipe that creates a file if it's missing and then tries to insert some lines in it.</p>
  
  <pre><code>file "/root/myfile" do
    owner 'root'
    group 'root'
    mode '400'
    action :create_if_missing
  end
  
  file = Chef::Util::FileEdit.new('/root/myfile') 
  
  data_bag('my_databag').each do |user|
  
    # ... lines using Chef resources like user, group, etc.
  
    if node.chef_environment != "my_env"
      line = "something to write in myfile"
      Chef::Log.info("-----&gt; #{line}") 
      file.insert_line_if_no_match(/#{line}/, line)
    end
  end
  
  file.write_file
  </code></pre>
  
  <p>The recipe fails in the case <code>myfile</code> doesn't exist despite I'm forcing the creation of the file before the instruction that causes the exception. So here is the error:</p>
  
  <pre><code>ArgumentError
  -------------
  File '/root/.testfile' does not exist
  
  Relevant File Content:
  ----------------------
   18:
   19&gt;&gt; file = Chef::Util::FileEdit.new('/root/.testfile')
   20:
  </code></pre>
  
  <p>Can anyone help me to understand why this doesn't work? Any help on this would be much appreciated.</p>
  
  <p><strong>UPDATE</strong>: I tried to touch the file first but still failing in the same line:</p>
  
  <pre><code> 26:  FileUtils.touch('/root/myfile')
   27&gt;&gt; file = Chef::Util::FileEdit.new('/root/.testfile')
  </code></pre>