There's no need to have an independent $cnt when you can use that name as the looping variable.
Also, what's wrong with that output? Maybe you could check that the page is loading properly, for example, by testing defined($content) && length($content)