You could do it like:
< "$file_path" awk -v x="$first_line" -v y="$second_line"' NR == x {printf "%s", $0; next} NR > x && NR <= y {printf "%s", ORS $0}' | base64 -w0
You could do it like:
< "$file_path" awk -v x="$first_line" -v y="$second_line"' NR == x {printf "%s", $0; next} NR > x && NR <= y {printf "%s", ORS $0}' | base64 -w0