Fix leftover detection

The mod variable was being shadowed, which caused the file 'M' to be written to.
Since the filesystem is now read-only, this caused the check to error out and
not finish.