filerepo: Replace confusing substr() with rtrim()