Nit: the parentheses around `str.size - str.rindex("\n")` are unnecessary.