As long as you were only running this when the player finishes a level or gets a game over, that wouldn't be an issue. That's mostly what myself and
@IndianaBones are getting at: writing to the files is fine as long as you aren't constantly doing it. But there are problems in your example. If you were to
keep beating the high score you'd be constantly opening and closing this file, which is not good. Secondly, why wouldn't you just read the high score into some variable and just check
that? It would be much better to have the high score table saved into memory, read when the game starts and written when the game ends.
Generally you want to avoid constantly opening and closing files. Even if your game runs fine, it's also just a really bad habit to get into.