perl -ni -e "BEGIN{print qq/Enter new student name: /; chomp( $student = ); $found = 0 } $found++ if /^\Q$student\E\s*$/i; print $_ . (eof and not $found) ? qq/$student\n/ : qq//;" students.dat