The bug is caused by one of the headers sent in the output() method of HTTPResponse.php. If you call echo " ", then it's preventing headers from being sent and therefore fixing your output.
I suspect that it is this line is the culprit:
header("HTTP/1.1 $this->statusCode " . self::$status_codes[$this->statusCode]);
You might want to try changing it to this and seeing if that fixes it instead of the "echo" fix that you made.
if($this->statusCode != 200) header("HTTP/1.1 $this->statusCode " . self::$status_codes[$this->statusCode]);