rstrip doesn't do what you seem to think it does:

```python
In [1]: "apple.tex".rstrip(".tex")
Out[1]: 'appl'
```