Fix template file rewrite error.
Fix nonescaped special symbols in replacements.