They're probably not fruit flies, but fungus gnats. They can live off all sorts of stuff, mold or fungus in a potted plant, crap growing on a clogged filter, ect. You probably have some of your filter material sticking above the water line and they zero in on that, eating algae and whatever else is growing on it. See if you can completely submerge your media.. that should help. Otherwise, look to see what else is constantly wet that is sticking out of the water and might have something growing on it...