I use a plugin for gedit, but there are commands and plugins and bash scripts that can do the same thing.  like, say, cat input.txt | sed 's/[ \t]*$//' > output.txt