What can cause corrupt output files?

Recently, I was battling with corrupt output files. One of my routines prints out data to files with either println, or lately (when I was battling with the issue) with CSV.write. In both ways, I got corrupt files occasionally. Probably in 1 out of 20 files I create, part or whole lines are missing, or garbage appear on one line, or blocks of data are out of place.

I run Manjaro Linux via VirtualBox on MacBook Pro host. It looks (I am not positive) the corrupt files happen when they are written in VBox’s shared folders. I tried to write into VBox’s native folder and it appears OK so far.

I have been doing editing, copying and saving my source files to the shared folder for a long time and never run into any corrupted files. I wonder what can cause the file corruption when I write from a Julia routine. Any idea?

Not closeing files could in principle cause some missing output. But the first think I would look for is a bug in your code; remote filesystems either sync or not, but should not introduce corruption. You could test by writing to a local folder.

Files are properly closed.
I wrote 150 files to VBox’s native (local) drive, and they appear OK.