title: Add text to file if not exist
body: <p>I'm successfully adding file content with this script,</p>
  
  <pre><code>@echo off
  
  set hostspath=%windir%\System32\drivers\etc\hosts
  
  echo 99.127.158.114 www.example.com &gt;&gt; %hostspath%
  
  exit
  </code></pre>
  
  <p>However, if I run the bat file again, it add the lines again. And there are duplicates. What I want to do this, when I run the bat, it should make the file content empty, and then put the content (or check if addedi and not add). What is the correct way to do that ? </p>