remove a block of text in a file with python
<p>I am trying to remove a block of text in the apache configuration file, specifically virtualhosts.  I need to remove  the virtualhost containers including the &lt; VirtualHost> markers.<br></p>

<pre><code>Stuff

&lt;VirtualHost   asdfalsdkf:*&gt; 
asldkfjasl;dkfjasldkfj
asdfljasldjf;laksdfj
a;lsdkfj;laksjdfas
asldkfjasldfkj
3495034ijfgdl9)_*)(%$
more stuff
&lt;/VirtualHost&gt;

stuff
</code></pre>

<p>So far I have tried to regex it out.  but it is not changing the file.  I am actually trying to update the file and remove the code.  </p>

<p>This is what I have so far that is not working.</p>

<pre><code>for line in fileinput.input('/etc/apache2/apache2.conf.replace',inplace=True):
    sys.stdout.write(re.sub(r'&lt;VirtualHost.*?&gt;.*?&lt;/VirtualHost&gt;','',line))
</code></pre>
