awk '1; END {if (NR <= 2) print "another line"}' file
Here's another way just for fun: bash version 4
mapfile lines <file; (IFS=; echo "${lines[*]}"); ((${#lines[@]} <= 2)) && echo another line
better bash: tee into a process substitution
$ seq 3 | tee >( (( $(wc -l) <= 2 )) && echo another line )
1
2
3
$ seq 2 | tee >( (( $(wc -l) <= 2 )) && echo another line )
1
2
another line
$ seq 1 | tee >( (( $(wc -l) <= 2 )) && echo another line )
1
another line