Ok I turned it on and got a couple of warnings. The empty <h2> tag was actually because of an array i created that contains an empty element. The <h2> tags that should be output by the loop do not exist at all.
It’s worth mentioning that when I call the get_the_title(); outside the loop it works. So I think the problem is in the loop itself.