Modified fopen and fclose to use new exists(file) and is_opened(file) functions.