Moving file io functions into a better file'