Fixes #721 - loop with brackets inside conditional

Walks characters forward counting open brackets so the code doesn't accidentally insert *inside* the for loop. Added test too.