Fix path and fd usage