File write function, changing vars