fixes repeated reading from file