title: How to delete the whole line in batch file and retranslate it to the output file?
body: <p>As I am new here, I have some problems "coding" in batch file.</p>
  
  <p>I have an input-output file <code>file.txt</code> with some data (Name Surname Sex Age) and also have some functions that should be made with this file, e.g.:</p>
  
  <ul>
  <li>add a person,</li>
  <li>delete a person,</li>
  <li>sort people,</li>
  <li>exit,</li>
  <li>show the list</li>
  </ul>
  
  <p>The main problem happens when I choose the function to delete a person. I have tried to overwrite the file with <code>type %~f1 | findstr /v %name% &gt; %~f1</code>, but it deletes everything from the input-output file. I have also tried <code>type %~f1 | findstr /v %name% &gt;&gt; %~f1</code>, but it adds some lines that I do not need...</p>
  
  <p>I need a function that would delete the whole line, which contains the entered name (or surname) and would show me the output file without that line.</p>
  
  <pre><code>@echo off
  
  :PAT
  cls
  color 4f
  
  echo.
  if exist %~f1 (
      rem goto PRA
  ) else (
      echo ERROR
      goto END
  )
  
  :PRA
  echo Menu:
  echo 1) Add a person
  echo 2) Delete a person
  echo 3) Sort
  echo 4) Exit
  echo 5) Show the list
  
  echo.
  choice /c 12345 /m "Choice: "
  
  
  if errorlevel 5 goto AAA
  if errorlevel 4 goto END
  if errorlevel 3 goto SOR
  if errorlevel 2 goto DEL
  if errorlevel 1 goto ADD
  
  :EOF
  pause
  
  :END
  choice /m "Continue?"
  if errorlevel 2 goto NE
  if errorlevel 1 goto TAI
  
  :TAI
  cls
  goto PAT
  
  :NE
  Exit
  
  :SOR
  
  echo Which sort?
  echo 1: A-Z
  echo 2: Z-A
  
  choice /c 12 /m "Choice: "
  
  if errorlevel 2 goto ZTA
  if errorlevel 1 goto ATZ
  
  :ATZ
  type %~f1 | sort /+1 /o %~f1
  cls
  goto PRA
  
  :ZTA
  
  type %~f1 | sort /+1 /r /o %~f1
  cls
  goto PRA
  
  :DEL
  
  echo Enter the name:
  set /p name=
  type %~f1 | findstr /v /i %name% &gt; %~f1
  goto PRA
  
  :ADD
  
  set /p name=Enter the name: 
  set /p surname=Enter the surname:
  set /p sex=Enter the sex:
  set /p age=Enter the age:
  echo %vardas% %surname% %sex% %age%&gt;&gt;%~f1
  echo.
  cls
  goto PRA
  
  :AAA
  cls
  echo _________________________
  more %~f1
  echo _________________________
  goto PRA
  </code></pre>