Looks like you don't need this extra check if you do "}" instead of "}\n" when u're creating and populating the array