title: Is it possible to do "if file exists then append, else create new file" shorter than this
body: <p>I have the following code but I'm trying to shorten it about one or two lines, as I believe the <code>if</code> is unnecessary. Is there any way the code below can shortened to a singular line?</p>
  <pre><code> if(file_exists($myFile))
      {
          $fh = fopen($myFile, 'a');
          fwrite($fh, $message.&quot;\n&quot;);
      }
      else
      {
          $fh = fopen($myFile, 'w');
          fwrite($fh, $message.&quot;\n&quot;);
      }
      
  </code></pre>