add error checking to open.c