fix bug in nextFilePath, add withTempDir'