errorhandling for fprintf to stdout