readahead-analyze: avoid division-by-0

Also remove a few casts and use _cleanup_fclose_ to simplify logic.