Added error checking to closing a file and fixed some errors in C_TEST.ham