I want to trap errors with my err function, which writes to the stderr. But in this example I am getting two error lines. How can I remove the first error msg not generated