Restructured code, trying to read external data file but failing