test for file before reading