Appending 'nextChar' here is wrong I think..
e.g. if it's 'abc]]d' - it's going to output 'abc]]]'