Updated to work properly when called through sudoedit.