Refactor: end_with? is more readable than match(/\n$/)