Use nanosleep() for file writing.