Fix bug with trailing / on input ending up in output filename