He has a girlfriend but....

so I met this guy at the beginning of the year, he's really nice and we started studying together. we would always tend to flirt but I thought it was just normal. Until we added each other on facebook and I found out he had a girlfriend. I never brought it up and neither did he. We started studying more and more and he would text me. I would never text him first. Long story short I have really really started to like him. me and him are so similar and we get along great, he is seriously my definition of perfect guy. My friends would tell me that I needed to tell him I liked him but I am way to shy for that and I don't see the point in telling him since he has a girlfriend. one time we were studying we just talked the entire time and hit it off perfectly. there have been people in my class that ask me if me and him were dating since we look at each other during class a lot. the one and only time he brought up his girlfriend was when he was saying he was mad at her for something. since we are on Christmas break I have not seen him and he told me he wouldn't be in the next semester class with me. I thought I could get over him since I wouldn't see him during break or in class anymore but one time over break he called me at 1 am asking about a class to take. he told me that he signed up for 2 of the classes I am in. we had a short convo then he texted me. we were talking till about 245 in the morning when I asked him why he was still awake. his reply was very flirty and we continued to flirt he surprised me by saying something somewhat dirty. he suddenly said he needed to stop before he got in trouble, I asked him stop what and he said we both know. he ended up saying since he had a girlfriend he shouldn't say stuff like that to other girls. he apologized and said he felt like a jerk and he didn't want me to stop talking to him. I don't understand why he brought his girlfriend up at that moment and not before. I haven't talked to him since and I feel awkward since I'm going to have him in my classes next semester. I like him a lot and I don't want this to end. I know he has to have some feelings for me but he has his girlfriend. what should I do to remain friends with him and avoid awkwardness. I'm confused of why we have flirted half the year, then he texts me and all that happens he tells me he has a girlfriend but he doesn't want me to stop talking to him. I would really love guys opinions on this as well as girls! thanks :)
He has a girlfriend but....
Post Opinion