Clean up example: use context manager when opening files (already done elsewhere in the file), use  rather than %s, remove trailing spaces on a number of lines, break lines at under 80 characters