Thanks for your responses guys. I figured out what was wrong.
The code was working fine. On going into the command window to check the file attributes, I discovered that the name of the file I was trying to open wasn't "XMLTest.txt" but "XMLTest.txt.txt" - I had changed the name in Windows Explorer and for some reason it had kept the extra .txt on the end. I removed that and all was well. So, it had read and write permission (as per RAGE's suggestion, which was what I was checking) - it just didn't have the name I wanted it to have.
As a wise man once said, "AAAARRRRGGGGHHHH!!!!"