Updated file IO to be handled better.