Are the files being written to a MicroSD card? If so, you might be a victim of flash fraud; something where the capacity of the storage is actually a lot lower than it is advertised to be. You can use a program like h2test to write files up until the full capacity of the card, and then have it read all the data back to verify its true capacity. There are other alternatives out there, but it is the most reliable (and slowest) method. Plus you would want to make sure to keep a backup of all the files on it.