use sed instead of echo $ >> fn