|Editing files from a batch script has been somewhat neglected, there are 3 main choices, running the whole file through a for loop and into a new file, third party utilities or the antiqued dos edlin that is not included with 64bit systems.|
In both of the examples below it is important that your number is always on the very first line.
In your case using the for loop method may look something like:
>newfile echo %num%
for /f "usebackq skip=1 delims=" %%a in ("your text file.txt") do >>newfile echo %%a
move "newfile" "your text file.txt"
This will skim out any empty lines, if the empty lines are important steps can be taken to preserve them.
Here is a way that involves the antiqued edlin dos executable that isn't and won't be present in 64 bit systems. I don't recommend this method but I will outline it any way.
start /b /wait cmd /c "(echo 1&echo %num%&echo exit)|edlin file.txt&exit"
The reason I used start is to try and kill off ntvdm(nt virtual dos machine) without actually killing off the process in case it is in use. The edlin method has quite a few drawbacks, to mention a couple it can't handle long file names and always leaves a ^z end of file character at the end of the file.