replace file -> open for PYthon3 compatibility