Added check to see if endIndex token is comment and append EOL if it is

This is to fix #630