title: how am I copying this html into itself?
body: <p>Ive got a very simple html. with a few divs in it to fill with data.
  below is my index.html</p>
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang=&quot;en&quot;&gt;
  &lt;head&gt;
      &lt;meta charset=&quot;UTF-8&quot;&gt;
      &lt;title&gt;GOG  init&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
     &lt;h1&gt; GOG  new :) &lt;/h1&gt;
     &lt;div id = &quot;card1&quot;&gt;&lt;div id =&quot;name1&quot;&gt;&lt;/div&gt;&lt;div id =&quot;price1&quot;&gt;&lt;/div&gt;&lt;/div&gt;
     &lt;div id = &quot;card2&quot;&gt;&lt;div id =&quot;name2&quot;&gt;&lt;/div&gt;&lt;div id =&quot;price2&quot;&gt;&lt;/div&gt;&lt;/div&gt;
     &lt;div id = &quot;card3&quot;&gt;&lt;div id =&quot;name3&quot;&gt;&lt;/div&gt;&lt;div id =&quot;price3&quot;&gt;&lt;/div&gt;&lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  <p>i have written a python script which grabs some data from gog.com to fill the html and i fill the html below by simply replacing 2 lines.</p>
  <pre><code>#bunch of stuff to get names n prices ...... 
  
  of= open(&quot;index.html&quot;,&quot;r&quot;)
  html_page=of.read()
  of.close()
  
  with open(&quot;index.html&quot;,&quot;w&quot;) as f:
      to_replace='&lt;div id = &quot;card1&quot;&gt;&lt;div id =&quot;name1&quot;&gt;{}&lt;/div&gt;&lt;div id =&quot;price1&quot;&gt;{}&lt;/div&gt;&lt;/div&gt;'.format(name1 , price1)
      f.write(re.sub(r'&lt;div id = &quot;card1&quot;&gt;&lt;div id =&quot;name1&quot;&gt;&lt;/div&gt;&lt;div id =&quot;price1&quot;&gt;&lt;/div&gt;&lt;/div&gt;', to_replace, html_page))
      to_replace='&lt;div id = &quot;card2&quot;&gt;&lt;div id =&quot;name2&quot;&gt;{}&lt;/div&gt;&lt;div id =&quot;price2&quot;&gt;{}&lt;/div&gt;&lt;/div&gt;'.format(name2 , price2)
      f.write(re.sub(r'&lt;div id = &quot;card2&quot;&gt;&lt;div id =&quot;name2&quot;&gt;&lt;/div&gt;&lt;div id =&quot;price2&quot;&gt;&lt;/div&gt;&lt;/div&gt;', to_replace, html_page))
  </code></pre>
  <p>Below you can see the final result of my html. it seems to copy itself, including parts of the head.</p>
  <pre><code>&lt;body&gt;
  &lt;h1&gt; GOG  new :) &lt;/h1&gt;
     &lt;div id=&quot;card1&quot;&gt;&lt;div id=&quot;name1&quot;&gt;Pillars of Eternity II: Deadfire - Obsidian Edition ,,,  Outward&lt;/div&gt;&lt;div id=&quot;price1&quot;&gt;18.00&lt;/div&gt;&lt;/div&gt;
     &lt;div id=&quot;card2&quot;&gt;&lt;div id=&quot;name2&quot;&gt;&lt;/div&gt;&lt;div id=&quot;price2&quot;&gt;&lt;/div&gt;&lt;/div&gt;
     &lt;div id=&quot;card3&quot;&gt;&lt;div id=&quot;name3&quot;&gt;&lt;/div&gt;&lt;div id=&quot;price3&quot;&gt;&lt;/div&gt;&lt;/div&gt;
  
      &lt;meta charset=&quot;UTF-8&quot;&gt;
      &lt;title&gt;GOG  init&lt;/title&gt;
  
     &lt;h1&gt; GOG  new :) &lt;/h1&gt;
     &lt;div id=&quot;card1&quot;&gt;&lt;div id=&quot;name1&quot;&gt;&lt;/div&gt;&lt;div id=&quot;price1&quot;&gt;&lt;/div&gt;&lt;/div&gt;
     &lt;div id=&quot;card2&quot;&gt;&lt;div id=&quot;name2&quot;&gt;Outward&lt;/div&gt;&lt;div id=&quot;price2&quot;&gt;13.99&lt;/div&gt;&lt;/div&gt;
     &lt;div id=&quot;card3&quot;&gt;&lt;div id=&quot;name3&quot;&gt;&lt;/div&gt;&lt;div id=&quot;price3&quot;&gt;&lt;/div&gt;&lt;/div&gt;
  
  &lt;/body&gt;
  </code></pre>
  <p>How does it copy the whole thing? what am i doing wrong?</p>
  <p><a href="https://i.stack.imgur.com/BLiux.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BLiux.png" alt="enter image description here" /></a></p>