Fix reading files multiple times