Added code to clear errno