Replaced try-except block with file check