fix #33. Don't call WriteHeader more than once