build: module: config: Add better file handling

From this commit on, we explicitly close our files. I don't trust java
on this one.

Signed-off-by: Bart Kuivenhoven <bemkuivenhoven@gmail.com>