I was watching this masterpiece Memento, but one question that stuck in my mind is how does Leonard remember reading and writing? He was suffering from short term memory loss and if reading and writing was in his permanent memory then why didn't he remember his name? His name must be in permanent memory too.
Remembering skills is different from remembering facts, and memory is very complex.
Forgetting your name is different from forgetting language. For example someone suffering from amnesia might forget whether they like the taste of an apple, but they know what an apple is.
If you argue that Leonard would forget reading and writing because he learned those skills a long time ago, why wouldn't he forget all language, including spoken? Wouldn't he regress to the mental state of a baby? No. His memory of events and facts is different from his understanding of language.
For more reading, see this article on language memory and amnesiacs.
Besides, as others have pointed out, he can actually remember everything from before a certain point, so the premise of the question is flawed. That said you can't make hard rules about memory and say it's a 'plot mistake' if they are broken. Memory is complex.
This question is built on a false premise. At no point does Leonard forget his own name. One of the first lines spoken is Teddy calling him “Lenny”, to which Leonard responds “it’s Leonard”:
(Ignore the weird doodle).
All he forgets are events that happened after his attack.
He says it himself several times in the movie: "I can't form new memories." His condition doesn't cause him to forget what happened before his brain was damaged, it only prevents him from forming new memories.
The injury suffered by the main character of Memento was inspired by the real-life case of Henry Molaison, aka H.M.,1 who lost the ability to form new memories (anterograde2 amnesia) as an unexpected side effect of brain surgery.3 A great deal of what we know about the brain, memories, and amnesia are a result of the H.M. case; his tragedy is the only reason that science was able to determine a lot of things about human memory.
In particular, case studies of H.M. cemented the distinction between explicit memories and implicit or procedural memories—that is, memories of events that have occurred in our lifetimes, versus memories of how to perform particular tasks. Not only did H.M. not forget how to do things he had learned, he was able to learn how to do new things, despite having no memory of having learned them. He learned to touch-type: if you showed him a typewriter or keyboard, he would claim to have never seen one in his life, but he could sit down and type with ease. He learned several artistic skills he had never had before the accident. He could even draw you a map of the house he lived in, despite having moved into it several years after he stopped producing personal memories and having no memory of having lived there before.
In this regard, Memento is actually quite accurate.4 Leonard not only could remember how to do things before his injury, but could even learn how to do new things, and even though he wouldn’t remember learning them, he’d still be able to do them.
See How the man who inspired ‘Memento’ changed our understanding of memory in The Verge, The Man Who Forgot Everything from The New Yorker, etc. I haven’t found an explicit statement from Nolan or others involved in the movie referencing H.M., but many sources assert it. Others state only that the cases seem reminiscent of one another, etc.
As opposed to retrograde, which in the case of amnesia refers to the loss of old memories. Henry Molaison actually also suffered some retrograde amnesia, losing the memories of a couple of years prior to the surgery. While that would be a devastating side effect in most cases, here it pales in comparison to the anterograde amnesia.
The surgery was an effort to cure his extremely severe epilepsy, and it was actually successful in that.
Which is not to say that Memento is a particularly accurate film overall; it is, in fact, a heavily stylized film. One notable departure from reality: another famous amnesiac, Clive Wearing, refused to believe he had written notes or journal entries, despite them being in his handwriting and him being informed of his condition, on the basis that he did not remember writing them and therefore could not believe that he had. He kept writing in his journal, despite believing all of the previous entries to be fabrications. It is therefore unclear if Leonard’s notes and tattoos trick would ever work.