Modifying an external file is possible using Perl. I placed a test.txt file in my graphics folder and was able to successfully write to it by placing this script in my survey:
[% Begin Unverified Perl
my $file = '../../graphics/test.txt';
open (my $fh, '>', $file) or die 'File could not be opened';
print $fh 'Hello world!';
End Unverified %]
(The above code should work for local testing. For the live survey, remove one of the "../" from line 2.)
So it is certainly possible to modify your .htm file using this technique. The exact code needed will depend on exactly how you need the .htm modified.