The best tool I have used is Vi.
(sudo) vi /home/mydoc.txt will open and allow you to do any editing you need done. If you have never used Vi before, there are some great HOW-TO's and tutorials online. Here is one:
But I'd encourage you to really read and experiment on test files before you change the file you are referencing, AND, PLEASE, make a backup up the file ( cp /home/mydoc.txt mydoc.txt-orig ) before you do. You can always remove the edited file that does not work, but restoring the original after extensive exiting can be a hair-pulling experience.