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

This is to fix #630
Could you tabulate whole test code?