Revert "Revert "Bug fix with file ending""

This reverts commit c9f79d476034315ae33d74ce55ee2b0645b51d9f.