Corrected the line removal to leave the last newline in tact