use committed() instead of opening the file just to get the filename

committed() returns the filename. Use this method instead of opening the file, reading the filename, then closing the file.