Fixed error-checking
Added binary flag to i/o descriptors (needed in this case?)