guard against trailing newlines