How to remove exisiting file content from a file and have to append new file content?

hi all,
i had the below script

x=`cat input.txt |wc -1`
awk 'NR>1 && NR<'$x' ' input.txt > output.txt

by using above script i am able to remove the head and tail part from the input file and able to append the output to the output.txt but if i run it for second time the output is getting appended to the existing output file...i want to clear the content of the file before appending the output...how i can i acheive it ..?

thanks in advance

regards,
Vasa hemanth saikumar.

your code should over-write the existing data.
If it still appends,

x=`cat input.txt |wc -1`
>output.txt
awk 'NR>1 && NR<'$x' ' input.txt > output.txt

I'd be highly surprised if that would NOT entirely overwrite output.txt , as >> is the redirection operator for appending. On the other hand, x won't be defined, as wc does not have a -1 option and your assignment statement will produce an error.