Eliminated array_pop in read_file function