Add open_file function and fix some print format