title: moving file pointer up one line (php)?
body: <p>I am attempting to automate the sitemap.xml file on my site since the content is constantly changing.  I currently open the file for appending: <code>fopen($file_name, 'a');</code> so that I can add the new set of  tags.  However, I just noticed that the entire sitemap file has to be ended with a  tag which means that every time I open the file, I need to append the text not to the end of the file, but to 1 line from the end.</p>
  
  <p>So basically, how can I move the file pointer up after opening the file for appending so that I can achieve this?  Thanks.</p>
  
  <p><strong>Update:</strong> here is what the sitemap looks like:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;urlset xmlns="http://www.google.com/schemas/sitemap/0.84"&gt;
      &lt;url&gt;
          &lt;loc&gt;...&lt;/loc&gt;
          &lt;lastmod&gt;2009-08-23&lt;/lastmod&gt;
          &lt;changefreq&gt;weekly&lt;/changefreq&gt;
          &lt;priority&gt;0.8&lt;/priority&gt;
      &lt;/url&gt;
      &lt;/urlset&gt;
  </code></pre>
  
  <p>so whenever I append, i need to add the <code>&lt;url&gt;..&lt;/url&gt;</code> part which must go right before the closing <code>&lt;/urlset&gt;</code> tag.  I already have code that can append the xml to the end of the file.  I just need to figure out how to append the new portion <em>right before</em> the closing tag.</p>