Try this instead:
RewriteCond %{SCRIPT_FILENAME} !/w.htm$
RewriteRule ^(.*)\.htm $1.php [nc]
Also, if you had any old .html files, you could also redirect both .htm and .html using one pattern:
RewriteCond %{SCRIPT_FILENAME} !/w.htm$
RewriteRule ^(.*)\.html? $1.php [nc]
Finally, if anyone has the old URL bookmarked (or if search engines are still hitting it), you should set the proper HTTP status code to indicate that the old URL is no longer valid:
RewriteCond %{SCRIPT_FILENAME} !/w.htm$
RewriteRule ^(.*)\.htm $1.php [nc,R=permanent]
(replace permanent with 301 if not using Apache 2.0+).