Added exception handling for IO