Assuming you're on a Windows platform, due to your provided code and included tags…
The folowing batch-file example will remove spaces and tabs and also remove any blank lines:
@If Exist "CODE_CHECK.txt" (For /F Delims^=^ EOL^= %%A In ('More /T1 "CODE_CHECK.txt"')Do @Set "$=%%A"&Call Echo(%%$: =%%)>"CODE_CHECK_2.txt"
To maintain any blank lines, using a batch-file, you'd need something more like this:
@If Exist "CODE_CHECK.txt" (For /F "Tokens=1*Delims=]" %%A In ('More "CODE_CHECK.txt"^|Find /V /N ""')Do @Set "$= %%B"&Call Echo(%%$: =%%)>"CODE_CHECK_2.txt"
In this example I've removed the /T1 option for More, I'm unsure if its inclusion is more or less efficient
You could also use powershell for this, (if needed the input and output file can be the same):
(GC 'CODE_CHECK.txt') -Replace '\s',''|SC 'CODE_CHECK_2.txt'
You can also run the powershell version from a batch-file:
@PowerShell -NoP "(GC 'CODE_CHECK.txt') -Replace ' |\t',''|SC 'CODE_CHECK_2.txt'"
In this version, I've used ' |\t', as a possible alternative to '\s'.