remove extra newlines from the end of file