According to the documentation I found, WriteHeader returns an error, which should be checked.