You need the pick your homeless person carefully if you do this. There's a nontrivial chance it will result in verbal harassment and/or a confrontation.
Maybe first ask if that's ok? "Can I buy you a sandwich" is a lot more friendly than "here's a sandwich".
I've made that exact mistake myself, but I think this may be the better approach.