make file reading synchronous; eliminate race condition