Some important notes:
- $widgetsFound is not intialised at the start, which can lead to an undefined value that is printed (if there are no widget in the first database-section)
- The printing of the last database section is always done, even if the file would be empty, which will lead to three undefined values being printed.
An unimportant note: I posted similar code as a reply to the OP's node before you did :)