Not sure what's your level, so I'm not sure what would be good advice for you.
Please share what you have thought about so far.
In any case, I would split the code to
- representing the maze (with a class assuming you already learned about classes)
- parsing the maze from the text file (and returning an instance of the mentioned class)
- solving a maze using the basic algorithm
- solving a maze using the "shortest path" algorithm