use fprintf instead of printf