title: Write file on php
body: <p>I want to keep ips from visitors and place them on a file.<br>
  I tried fwrite() function but I think it is rewrite on the previus ip on file.</p>
  
  <p>Example.</p>
  
  <p>ip.txt is empty.</p>
  
  <p>when I run the write.php Script, on ip.txt I have x.x.x.x  ip  (my ip)</p>
  
  <p>If My friend runs the write.php Script, on ip.txt I have a.a.a.a  ip (friend's ip only) </p>
  
  <p>where is my ip? 
  I want to have on ip.txt file the following:</p>
  
  <pre><code>x.x.x.x   ip1  
  a.a.a.a   ip2
  </code></pre>
  
  <p>Code on  write.php is the following.</p>
  
  <pre><code>&lt;?php
  $file = fopen("ip.txt","w");
  $ip=$_SERVER['REMOTE_ADDR'];
  echo fwrite($file,$ip);
  fclose($file);
  ?&gt; 
  </code></pre>