Rory McIlroy promised never to make the same mistake again after a two-shot penalty.