AIFile bug fixes.

Compare with errno instead of rc.
Make sure errno is preserved.