Added file writing back. I forget why. Took out extra crap