@echo off for /f "delims=" %%a in (test.txt) do ( echo "%%a"|find "num_a" &&echo %%a >>newtest.txt ) echo end... pause