Naturally, Pharaoh was punished for taken Sarai, but I feel the clear message God was sending to Pharaoh is "...do my prophets no harm." I say this because in chapter 20, we see where Abraham prayed for Abimelech and his family because God had closed the womb of the women in his household for taking Sarah, and God heard his pray and the women were able to bear children. When everyone got sick in Pharaoh's house he realized the connection, between his household sickness and the taking of Sarai, maybe God gave his some warning, this is not clear as how he made the connection, but he did correct the situation and returned Sarai and told them to leave his area. God may have been trying to reach Pharaoh's heart for him to repent for his sins, and used this as a way to get his attention. We see another issue of this kind in Daniel where King Nebuchadnezzar was reduced to crawling on the ground and acting strange for seven years, because of his pride. We do know that Pharaoh returned Sarai to Abraham, and maybe that was all God wanted to accomplish, we don't know what long term effect this had on Pharaoh because we don't hear about him anymore.