remove trailing whitespace when extracting metadata