added check the the file handle returns succesfully