try except around file open