Does this help?
--Button script
CreateNewFile()
function CreateNewFile()
	local MyNum = wx.wxGetNumberFromUser("Select or enter a feed rate", "Feed Rate:", "Enter Feed Rate", 50, 1, 1500) --Default, min, max
	local MyGcode = string.format("(File created using CreateNewFile function)\nF%0.4f", MyNum)	
	local MyFile = wx.wxGetCwd() .. "\\GcodeFiles\\MyFile.tap" --Define the file name and location
	file = io.open(MyFile, "w+") --Open the file in update mode, all previous data is erased
	--file = io.open(MyFile, "a+") --Append update mode, previous data is preserved, writing is only allowed at the end of file.
	file:write (MyGcode) --Write the Gcode file
	file:flush (MyFile) --Save written data
	file:close (MyFile) --Close file
	
end