Deleting lines of text

I’m trying to convert an RSS feed into something I can parse with Applescript. To do so, I need to remove a couple lines from the file. I tried “delete line 4”, which compiles fine, but doesn’t actually work, whether it’s deleting it from the text as a variable or from the actual file itself. More specifically, I need to delete the lines marked with a * in this file:

<?xml version="1.0" encoding="UTF-8"?> <rss version="2.0"> <channel> *<title>Aaron's Test</title> *<link></link> *<description>Test</description> *<pubDate>Tue, 03 Oct 2006 18:00:55 -0400</pubDate> *<generator>Schoolhouse (1.1)</generator> <item> <title>New Assignment</title> <link></link> <description></description> <schl:course>New Course</schl:course> <schl:priority></schl:priority> <schl:kind></schl:kind> <schl:dueDate>09/16/2006</schl:dueDate> <schl:startDate>09/16/2006</schl:startDate> <schl:grade>75</schl:grade> </item> <item> <title>New Assignment</title> <link></link> <description></description> <schl:course>New Course</schl:course> <schl:priority></schl:priority> <schl:kind></schl:kind> <schl:dueDate>07/08/2006</schl:dueDate> <schl:startDate>07/08/2006</schl:startDate> <schl:grade>100</schl:grade> </item> <item> <title>New Assignment</title> <link></link> <description></description> <schl:course>New Course</schl:course> <schl:priority></schl:priority> <schl:kind></schl:kind> <schl:dueDate>09/16/2006</schl:dueDate> <schl:startDate>09/16/2006</schl:startDate> <schl:grade>87</schl:grade> </item> </channel> </rss>
The content of the lines is not constant, although their numbers (e.g. line 4, line 5, line 6, etc.) are. So, in short - how should I go about removing those lines from the file? Any and all help is greatly appreciated.

set theFilePath to "Macintosh HD:Users:jed:Desktop:file.txt"
set theFileContent to read file theFilePath

set exclusionList to {4, 5, 6, 7, 8}
set theCleanText to ""
set delim to ""

repeat with tmpIndex from 1 to (count paragraphs of theFileContent)
	if not (exclusionList contains tmpIndex) then
		set theCleanText to (theCleanText & delim & paragraph tmpIndex of theFileContent) as string
		set delim to return
	end if
end repeat

return theCleanText


Thanks a ton - the code you posted works great! :smiley: I’m kind of surprised you have to get that elaborate…one would have thought that deleting a line would be a matter of typing just that. Thanks again!