Wrong, incidentally, if you put a few drops of detergent in the vinegar.
Flies in general, fruit flies in particular, are attracted to rotting food, especially fruit. Where does vinegar come from? Rotten food, usually fruit (well, not anymore... most vinegar sold as white vinegar is distilled from malt vinegar due to its low cost, but you get the point) and as such it smells like nice, perfectly seasoned vittles to a fly. So the fly buzzes over to get it some tasty vinegar, and lands on the surface. Now usually, the surface tension of the vinegar would be more than enough to support the weight of a tiny little fly. But. The detergent in the vinegar acts to lower the surface tension to almost nothing, so the fly sinks and drowns, never to be seen again.
This is actually a very good way to get rid of a fruit fly infestation, if you have one. Seal up all other foods and leave a shallow bowl of vinegar (I use cider vinegar, it seems to work very well) out on the counter. Change it out every few days, and presto. No more flies.
Grandmother, you lied to me.