The chip keeps resetting everytime I try writing.
Sounds more like a hardware problem.
What programmer are you using?
Do you have a current schematic?