removing extra lines at the end of the file