Changed from C-style to C++-style file handling