added file IO exception handling