Add IOError handling