I know what it's like to want to reach out to someone, who is sad, without it seeming like more than a friendly gesture. I once ran into a girl crying in the grass at a park. As I asked her how she was doing and sat down to chat with her, she suddenly tried kissing me. I made it clear that sexuality was not my intention. After an awkward moment, she understood where I was coming from. We continued speaking for at least an hour, and at the end of it she actually thanked me that I didn't take advantage of her in a sexual way. During the conversation I stayed on topic, and did not let things drift into sexual undertones. That is my advice to you: You need to make your intentions clear, and remain focused on the topic at hand. There is no way for the person to "know", at the start, that it's not more than a friendly gesture. They could assume, for example, that you're using their loneliness as a signal to approach them romantically. That would be a fair assumption on their part.
If you stick to your guns, don't allow yourself to be carried into the sexual fantasy that the young man might project onto the situation, and you let him know that you're there as a friend, you should be alright. That's what worked for me.