Correctly handles files being moved into scope and out of scope