If these are very thin white worms, they are likely Planaria. Presense of planaria usually indicates a presence of decaying elements in the tank, most likely food, combined with not enough water changing.
To prevent the problem from happening again, vacuum the gravel very well, and then start feeding less then you have been - watch the tfish eat the entire time, make sure food is not settling down into the gravel. If you don't do waterchanges very often, then increasing the frequency of them would be a good idea as well.
In the mean time, hopefully DrOizo's advice will help you, because short of tearing down and cleaning up the tank, I don't have any better solutions for getting rid of them (you can manually remove the visible ones of course)
Hope this helps