What type of flatworms do you have? Red Planaria? Acro Eating Flat Worms (aka AEFW)?
The treatment for each of those two pests are totally different and one cannot be used for the other.
The treatment for Red Planaria that yields ME the best success is
Saliferts Flatworm Exit......when used 100% as directed.
Spend a week siphoning out all the visible FW's you can reach.
Do it once or twice daily.
The day you decide to treat with FWE just make sure you have enough replacement saltwater available to do a 50% water change.
Also make sure you have fresh carbon rinsed and ready to run ACTIVELY, NOT passively.
There are additional steps/precautions I can recommend if you decide to treat this way for Red Planaria (flatworms).
If you discover the AEFW variety is your problem, Jeremy's link to the Levamisole treatment is a great, successful way to go.
Either way you need to determine which FW you're infested with.
Russ