Switched getchar to fread to properly process binary data.