remove and add lines at end of files