Changed file IO to get rid of errors