How can the issue of a trailing empty line in the last output line be addressed in PHP?

The issue of a trailing empty line in the last output line can be addressed by using the `rtrim()` function in PHP to remove any trailing whitespace, including newlines, from the end of a string. This function can be applied to the output string before it is echoed to ensure that there are no unwanted empty lines at the end.

<?php

// Sample output with trailing empty line
$output = "This is the last line\n";

// Remove trailing whitespace, including newlines
$output = rtrim($output);

// Echo the output without trailing empty line
echo $output;