* Can you please eliminate the redundant `{}`?  
* It's a bad idea to use `sapply` in a function because you never know what it's going to return - can you please vectorise instead (i.e. `gsub()` and `nchar()` both take vectors as inputs)
* `nchar(NA)` is 2 - is it ever possible for file to be NA?