the error is caused by any output between code blocks that comes before the session_start() or header() functions.
a space is output,
so is a blank line
so is an html comment or HTML code.
the only thing I can say about the change you made, is that it removed the output that was causing the error. I cant really tell why without seeing the original code in the original PHP file.