Prevent Headers from being sent

“Headers already sent” is not a WordPress error, it is PHP processing error message. Good explanation here; https://stackoverflow.com/questions/8028957/how-to-fix-headers-already-sent-error-in-php .

I suspect it might be caused by some characters (probably space characters) sent before your <?php code segment. Even space (or tab [code formatting] ) characters will cause an error.

And perhaps move your <ul> code to just above the while loop.