I've had this situation happen often enough for me that it's really starting to shit me, and I can't work out whether I'm playing the hand correctly and just getting bad beats, or if I'm playing the situation wrong.

So I'm playing NLHE and I say have something like KT, and the flop comes K-J-7 rainbow. So I have top pair. I am in position, so the other guys bets, say around half the pot. Obviously I'm not going to fold top pair at this stage, and the only things I have to worry about are a set, two pair or a King with a higher kicker. If they have less than that, like a pair of jacks or 7s, they're prob not going to call a raise. So I figure they might have a pair of jacks, or maybe they're bluffing, or maybe they have a better hand and I'm beat, so I just call, trying to minimise loses if I'm beat and maximise profits if I'm ahead.

The turn comes some brick card and he bets again, around half the pot. I figure he has something, although I can't rule out the possibility of a bluff, and there's still a lot of hands he could have that I can beat, including a semi-bluff to a straight, so I'm not willing to lay it down yet.

The 5th street brings a 10, which gives me two-pair, so even if he had a king with a higher kicker, or two-pair Jacks and sevens, I now have him beat. Unfortunately, that ten makes AQ the nut straight, which my opponent unfortunately has (unfortunately for me that is). He bets again, and I call. There were so many hands I could beat at that stage that it seemed like the correct move.

It seems to me like I played the hand correctly, and he played the hand terribly, and he just got lucky on the river. But then I may be wrong. Now that I know what he has, it seems the most likely solution would have been to reraise on the flop or the turn, since all he had was a gutshot straight draw, but then again someone who's willing to aggressively bet their draws is probably willing to aggressively semi-bluff reraise as well.

Any help in deciphering this situation would be greatly appreciated.