try this:
@echo off&setlocal
set "file=file.txt"
for /f "delims=[]" %%i in ('^<"%file%" find /n "="') do set "split=%%i"
(for /f "tokens=1*delims=[]" %%i in ('^<"%file%" find /n /v ""') do if %%i lss %split% echo(%%j)>"%file%.new1"
<"%file%">"%file%.new2" more +%split%
type "%file%.new?"
..output is:
file.txt.new1
test
test1
test2
test5
test
test1
test2
test5
file.txt.new2
test
test1
test2
test5
test
test1