Fixed error checking when adding a file