If you're lonely when you're not with him, it shouldn't be a big mystery as to why you're lonely: You're lonely because you want to be with him, and you're not.
If you're lonely when you're with him that's something else, and it isn't how things are supposed to be (needless to say). So, if you feel lonely when you're with him it may be the signal to think about changing the terms of the relationship - either taking a break, or agreeing to see other people. One way or another, and regardless of why, if you feel lonely when you're with him , there's something very wrong.
By the way, to clarify what I mean by "with him", I mean "in his physical presence" - not "with him", as in "supposed to be girlfriend and boyfriend, but not in each other's presence a good part of the time" (as a result of something like his being in the other country).