moved to fread from fgetc, finished write out