filter last \n after input