fixed fd leak in error pages