probably not something you did wrong, the extensions use a weighting system to determine where in the page the code gets added, in more cases than not, the delete record and delete file code order wont be an Issue, usually the delete record would happen first. you just happened on a scenario where the file delete needed to happen first.