It’s a standard approach to ensure all files have a newline at end of file (to avoid issues when using cat
on them among other things). Requiring files to not have a newline at end of file is therefore considered bad practice.
If you want to get rid of the newline when reading the file, use String.trim_suffix("\n")
when reading the file.