diff --git a/pandoc/sitemap.lua b/pandoc/sitemap.lua index 1870988..40f746a 100644 --- a/pandoc/sitemap.lua +++ b/pandoc/sitemap.lua @@ -150,13 +150,12 @@ table.insert(lines, "") local data = table.concat(lines, "\n") -- read existing data from output_file -local f = assert(io.open(output_file), "\n" .. - "[ERROR] could not open " .. output_file .. " for reading.") -local data_old = f:read("a") -f:close() +local f = io.open(output_file) +local data_old +if f then data_old = f:read("a"); f:close() end -- write to output_file if data changed -if data ~= data_old then +if not data_old or data ~= data_old then local f = assert(io.open(output_file, "w"), "\n" .. "[ERROR] could not open " .. output_file .. " for writing.") f:write(data)