Or maybe they weren't homeless? Giving unsolicited food to homeless people is sort of like asking a woman when the baby is due. It's also important to remember that they may be homeless but many homeless people still have their pride and feel awful about having to ask for handouts, let alone have people randomly take pity on them.
I've lived in downtown San Diego for a while, and I've taken to just getting to know some of the homeless people who hang around the 7-11 by my apartment and buying food for them when they ask me.
That being said, you did a good thing by trying :)