You don't need a several hundred lines Batch file to perform a replacement as simple as this one. The two-lines Batch file below do the same:
@set @a=0 // & cscript //nologo //E:JScript "%~F0" < myfile.txt > out.txt & move /Y out.txt myfile.txt & goto :EOF
WScript.Stdout.Write(WScript.Stdin.ReadAll().replace(/HEADER/g,"\x0C"));
For a further description of regular expression syntax, see this page.
EDIT
In order to easily test this program, you may modify it in this way:
@set @a=0 /*
cscript //nologo //E:JScript "%~F0" < myfile.txt > out.txt
move /Y out.txt myfile.txt
goto :EOF */
WScript.Stdout.Write(WScript.Stdin.ReadAll().replace(/HEADER/g,"\x0C"));
Then, open a command-prompt session and execute it from the command line in order to see in the screen any error message. For example:
C:>\Users\Antonio\test type myfile.txt
This is a data line
HEADER This is the first line at top of page
This is more data line
C:>\Users\Antonio\test test.bat
C:>\Users\Antonio\test cscript //nologo //E:JScript "C:\Users\Antonio\test\test.bat" 0<myfile.txt 1>out.txt
C:>\Users\Antonio\test move /Y out.txt myfile.txt
Se han movido 1 archivos.
C:>\Users\Antonio\test goto :EOF */
C:>\Users\Antonio\test type myfile.txt
This is a data line
♀ This is the first line at top of page
This is more data line