There is no doubt that supplication has an effect on changing what is written, but this change was also written because of the supplication. So, do not think that if you supplicate to Allaah that you are supplicating with something which was not written; rather the supplication is written, and what results from it is written. This is why we find that the reciter recites over the sick person and he is cured, and in the story of the military expedition which the Prophet sallAllaahu ‘alayhi wa sallam sent, they stayed as guests with a people, but they did not treat them hospitably, and it was decreed that a snake bit their leader, so they requested someone to recite something over him. The Companions, may Allaah be pleased with them, imposed the condition that they should be paid for that, and they gave them a flock of sheep, so one of them went and recited Surat al-Faatihah over him, and the man who was bitten arose as if he had been freed from shackles, that is, as if he was a camel which had broken free from its tethering rope. Therefore the recitation had an effect in curing the sick person.
So supplication has an effect, but it does not change what has been ordained, rather it is decreed because of it, and everything with Allaah is according to Qadar. Likewise all of the causes have an influence on the effects by Allaah’s permission, so the causes are written and the effects are written.