Integrated new default dictionary

also made python 3 compatible and closed file objects after opening.