I get “Cannot modify header information – headers already sent” when I change my theme

The issue is that your plugin should not be outputting anything to the browser on init. As you can see by the error, some code in pluggable.php is trying to set a header, but headers were already sent when your plugin sent output. If you want to output markup, you have to hook something in the page body, like wp_footer.