(refactor) changed for loops to be standard iterators
(refactor) added fail condition for unclosed section tokens
(feat) added error handling for closed tags that appear before opened tags