fixed use of "mode" rather than "file_mode"