Modified main function to read from file