Updated to trim trailing newlines