only open the file WHEN you need to

This commit is contained in:
2026-08-26 19:50:49 -06:00
parent dad2acc197
commit 6066e69b45
+3 -3
View File
@@ -13,9 +13,6 @@ local link = io.read("*line")
local title = input_file_name:sub(1, -5) -- assumes .txt extension local title = input_file_name:sub(1, -5) -- assumes .txt extension
local output_file_name = title .. ".md" local output_file_name = title .. ".md"
local output_file = io.open(output_file_name, "w")
assert(output_file, "Could not open \"" .. output_file_name .. "\"")
local frontmatter = { local frontmatter = {
"---", "---",
"title: \"" .. title .. "\"", "title: \"" .. title .. "\"",
@@ -29,6 +26,9 @@ if link and #link > 0 then
frontmatter[#frontmatter + 1] = "From [" .. link .. "](" .. link .. ")\n" frontmatter[#frontmatter + 1] = "From [" .. link .. "](" .. link .. ")\n"
end end
local output_file = io.open(output_file_name, "w")
assert(output_file, "Could not open \"" .. output_file_name .. "\"")
for _, line in ipairs(frontmatter) do for _, line in ipairs(frontmatter) do
output_file:write(line) output_file:write(line)
output_file:write("\n") output_file:write("\n")