in reply to Script to update a value in text file

perl -pe 's/\A([a-z]+)/$i=$1;++$i/e' [filename]

And sno & cno will be incremented. Um… CountZero has a more useful, if less literal, reply, really.