All *_open functions now tidy up after themselves (closing files that were opened) if allocations fail.